This is the php code:
$slavesites = array(
'Category1' => array('Anchor1', 'http://www.test1.com'),
'Category2' => array('Anchor2', 'http://www.test2.com')
);
foreach($slavesites as $category => $slavesite){
echo $category;
foreach($slavesite as $anc => $url){
echo $anc.'<br>';
echo $url.'<br>';
}
}
The problem is when I run the code, i get a “0” and “1”:
Category10 **--- WHERE DOES THE 0 COME FROM?**
Anchor1
1 **---- WHERE DOES THE 1 COME FROM?**
http://www.test1.com
Category20 --- WHERE DOES THE 0 COME FROM?
Anchor2
1 ---- WHERE DOES THE 1 COME FROM?
http://www.test2.com
Ty!:)
Hope you can help…
second foreach iterates over array without proper indices set. that way default indices (0,1,2,…) are used and hence the number in output.
e.g. actually your definition is like this:
you should use ‘list’ instead of ‘foreach’ in the inner loop: