how to insert a variable within the search array?
something like 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 would be the best way to do this?
Apologies if I misunderstood the question, but it looks like you're asking about how to have the first parameter of array_search() be variable in nature. PHP's string concatenation operator is the dot (.). As such, you should be able to do the following:
[...]
if(($key = array_search($imagename . '.png', $myImagesList)) !== false) {
array_splice($myImagesList, $key, 1);
[...]