I want to search and delete $srch_data data from the $list, but array_search() is not working. What's going wrong?
$srch_data = 'neha,[email protected]';
$list = "gaurav,[email protected],neha,[email protected],ayush,[email protected]";
$arr = explode(',',$list);
$list_array = array_chunk($arr,2);
$pos = array_search($srch_data,$list_array);
echo $pos;
The problem is that you are searching with different things. Once you have used
array_chunk(), your data is...and you are searching for
so this will not match.
If you converted your search string to an array as well, this will work...