I have an array:
$array = Array
(
[0] => qst
[1] => insert_question_note
[2] => preview_ans
[3] => _preview
[4] => view_structure_answer_preview
[5] => index
}
I need to unset the array keys based on elements in
$array_elements_to_be_remove = array('qst','_preview'); // or any string start with '_'
I tried to use:
$array_key = array_search('qst', $array);
unset($array[$array_key]);
$array_key_1 = array_search('_preview', $array);
unset($array[$array_key_1]);
Is there any other better ways to search batch of elements in $array ?
I expect that if I can use array search like this:
$array_keys_to_be_unset = array_search($array_elements_to_be_remove, $array);
I found a way to search the string if it is start with '_' as below:
substr('_thestring', 0, 1)
Any ideas how to do that?