我用谷歌搜索无济于事,我错过了一些如此基本的东西,我看不到它。
我有以下数组
$this->links = array (
0 =>
array (
'url' => 'http://maps.doc.govt.nz/Viewer/Index.html?viewer=rwa',
'text' => 'DOC maps: Discover the outdoors ',
),
1 =>
array (
'url' => 'https://booking.doc.govt.nz/',
'text' => ' ',
),
2 =>
array (
'url' => 'https://booking.doc.govt.nz/',
'text' => ' Book Great Walks, selected huts, campsites and more. ',
),
3 =>
array (
'url' => 'https://careers.doc.govt.nz/jobtools/jncustomsearch.searchResults?in_organid=18174&in_searchBut=Search',
'text' => 'Jobs at DOC ',
),
4 =>
array (
'url' => 'http://blog.doc.govt.nz/',
'text' => ' Conservation blog ',
)....
我试图用这个循环它
foreach ($this->links as $arrayId)
{
print "Link {\n";
foreach ($arrayId as $linktitle=>$linkdetail)
{
echo 'link: -'.$linktitle .'<br/> bit'.$linkdetail;
}
}
但我收到警告:为 foreach() 错误提供的参数无效。我真的不知道为什么它不起作用,我也尝试了我能想到的每一个变化?仍然得到同样的错误?
更新我转储变量并且 $links 被描述为一个数组但是当我添加一个 is_array 条件时它返回 false??????
var_dump($links);
- string 'array (
0 =>
array (
'url' => 'http://www.iana.org/domains/example',
'text' => 'More information... ',
if (is_array($links))
{
echo "Its an array";
} - does not return