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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -