phpの単純なxmlオブジェクトで問題が発生しています。
ログに次のxmlデータがあります
SimpleXMLElement Object
(
[@attributes] => Array
(
[title] => test
[scanner] => Data
[id] => WordData
[position] => 1800
[error] => false
[num] => 6
)
[subpod] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[title] => Surnames
)
[plaintext] => Common (US population: 650 people, white: 63% | black: 35%)
[img] => SimpleXMLElement Object
(
[@attributes] => Array
(
[alt] => Common (US population: 650 people, white: 63% | black: 35%)
[title] => Common (US population: 650 people, white: 63% | black: 35%)
[width] => 349
[height] => 18
)
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[title] => Cities
)
[plaintext] => Littleton Common (Massachusetts, 2789 people)
[img] => SimpleXMLElement Object
(
[@attributes] => Array
(
[alt] => Littleton Common (Massachusetts, 2789 people)
[title] => Littleton Common (Massachusetts, 2789 people)
[width] => 287
[height] => 18
)
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[title] => Buildings
)
[plaintext] => Rotunda on Woolwich Common (London, Greater London)
[img] => SimpleXMLElement Object
(
[@attributes] => Array
(
[alt] => Rotunda on Woolwich Common (London, Greater London)
[title] => Rotunda on Woolwich Common (London, Greater London)
[width] => 356
[height] => 18
)
)
)
.....more simpleXmlElement object
)
)
私のphp変数です$xmlObj = SimpleXMLElement Object
が、私が次のものを持っているとき
if (is_array($xmlObj->subpod)){
echo 'is array';
}else {
echo 'not array';
}
出力は常に「配列ではありません」であり、コードをエコーさせたい「配列です」
$xmlObj->subpod
配列だと思いました。テスト$xmlObj->subpod[0]->plaintext
すると、実際には文字列が返されます。この問題を解決する方法がわかりません。誰か助けてもらえますか?