In cake php how to avoid one or more elements in option array of select box.
$options = array('One','Two','First','Second');
echo $this->Form->select('trial', $options);
Here I want to avoid ‘First’ and ‘Second’ from array, here option array is coming from DB.
$options = array('One','Two');
Is it possible to do it by any alteration in select method of cake php(i.e array $attributes or anything else ) or manually search the array and drop the values ?
Use
array_slice():Edit:
An alternative solution, if you don’t know the order of the array, and if the values are unique, is by using
array_search():Or if the values aren’t unique and you’d like to remove them all, then
array_keys()could be useful: