Insert variable within the array search php -
how insert variable within search array?
something that
<?php $imagename = ' forest '; ?> <?php $myimageslist = array ( 'city.png' 'forest.png' 'fruit.png ' 'color.png' ); shuffle ($myimageslist); if (($key = array_search ("$imagename.png" $myimageslist))! == false) { array_splice ($myimageslist, $ key, 1); ?>
what best way this?
apologies if misunderstood question, looks you're asking how have first parameter of array_search() variable in nature. php's string concatenation operator dot (.). such, should able following:
[...] if(($key = array_search($imagename . '.png', $myimageslist)) !== false) { array_splice($myimageslist, $key, 1); [...]
Comments
Post a Comment