我需要從$ mydata變量中提取地址。從php中的數組中提取數據
我有這樣的代碼,讓我瞭解的數據:
foreach($landerssss['domains'] as $mydata)
{
echo '<pre>' . print_r($mydata, TRUE) . '</pre>';}
在上面的代碼
沒有錯誤的線婁節目什麼的$ MYDATA變量中。
這是什麼$ MYDATA變量中:
Array
(
[0] => Array
(
[address] => aloran
[mainDomain] =>
)
[1] => Array
(
[address] => ozamiz
[mainDomain] =>
)
[2] => Array
(
[address] => manila
[mainDomain] =>
)
[3] => Array
(
[address] => cebu
[mainDomain] =>
)
)
Array
(
[0] => Array
(
[address] => bacolod
[mainDomain] =>
)
[1] => Array
(
[address] => bukidnon
[mainDomain] => 1
)
[2] => Array
(
[address] => davao
[mainDomain] =>
)
[3] => Array
(
[address] => boracay
[mainDomain] =>
)
[4] => Array
(
[address] => palawan
[mainDomain] =>
)
[5] => Array
(
[address] => bohol
[mainDomain] =>
)
[6] => Array
(
[address] => calabarson
[mainDomain] =>
)
[7] => Array
(
[address] => NCR
[mainDomain] =>
)
[8] => Array
(
[address] => baguio
[mainDomain] =>
)
[9] => Array
(
[address] => manila
[mainDomain] =>
)
[10] => Array
(
[address] => cagayan
[mainDomain] =>
)
[11] => Array
(
[address] => iligan
[mainDomain] =>
)
[12] => Array
(
[address] => sindangan
[mainDomain] =>
)
[13] => Array
(
[address] => dipolog
[mainDomain] =>
)
[14] => Array
(
[address] => calamba
[mainDomain] =>
)
)
我需要提取所有的地址,所以我使用
foreach ($mydata[0]['sddress'] as $key) {
}
但IAM recieving錯誤的嘗試:
Warning: Illegal string offset 'address' in /srv/users/serverpilot/apps/ruleswitcherandchecker/public/CTAchecker/index.php on line 131
Warning: Invalid argument supplied for foreach() in /srv/users/serverpilot/apps/ruleswitcherandchecker/public/CTAchecker/index.php on line 131
請幫助:(
爲響應您好感謝,試圖固定錯字同樣的錯誤。 – ban