Monday 25 November 2019

php - Unset element in array

I want to unset 1 element in the array.
If for example I use GET and ?group=k



How do I unset "k" in the array?



This is the array:



$groups_array = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','a2','b2','c2','d2','e2','f2');



I have tried



   if(isset($_GET['group'])) {
unset($groups_array[1]);
$new_groupps_array = array_values($groups_array);
}


which works fine but where it shows [1] it needs to be a letter so I know how to unset it?




Hope you understand
many thanks

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...