Using a array variable in a foreach loop
Posted
by
Jess McKenzie
on Stack Overflow
See other posts from Stack Overflow
or by Jess McKenzie
Published on 2012-11-18T04:06:28Z
Indexed on
2012/11/18
5:00 UTC
Read the original article
Hit count: 251
I am having an issue trying to work out how to use a function variable in a foreach loop so that I can do the following but its not working.
$var =
array(7) { [0]=> array(3) { ["listingId"]=> int(532712629) } [1]=> array(3) { ["listingId"]=> int(532712202) }
Works but not right:
foreach($var as $varr)
{
var_dump($varr['id']);
{
Goal - Having the array variable as the foreach value
foreach($var['id'] as $item)
{
if($item === $foo)
{
}
}
© Stack Overflow or respective owner