PHP foreach and strpos newbie -
why doesn't work?
$statement = array( images_name[0] => 'small_01.jpg', images_name[1] => 'large_01.jpg', ); foreach ($statement->images $image): if (strpos($image->name, 'small')) { echo ('yes'); } endforeach
i can print image name without problem strpos
not working.
you must use:
foreach ($statement->images $image) if ( strpos($image->name, 'small') !== false ) { echo ('yes'); }
explained here: http://us3.php.net//manual/en/function.strpos.php
also, if want know why need use of "!==" or "===" read this: how php equality (== double equals) , identity (=== triple equals) comparison operators differ?
Comments
Post a Comment