Saturday, April 25

Remove single option from the selection list in PHP


// Array 

$myarray = $cars = array("Orange", "Apple", "Banana", "Cherry","Mango","Papaya");

echo "Initial array values </br>";
Print_r($myarray);

$value = "Papaya";  // remove value from the List

$options = array_diff($myarray, (is_array($value) ? $value : array($value)));

echo "</br> Result </br>";
Print_r($options);


Initial array values
Array ( [0] => Orange [1] => Apple [2] => Banana [3] => Cherry [4] => Mango [5] => Papaya )

Result
Array ( [0] => Orange [1] => Apple [2] => Banana [3] => Cherry [4] => Mango )


No comments:

Post a Comment

Backup files to google drive using PHP coding

 Dear All, To backup files to Google Drive using PHP coding, you can use the Google Drive API and the Google Client Library for PHP. Here...