I made this code in order to pick up a value a from an array, delete it, show the array without the deleted element and show which element has been deleted. If i run the code, the index number goes but the char stays.
Can you help me to understand where i'm wrong? What i would reach is just to have only the charset and then the charset with the missing value, but not the indexes.
<?php
// i create the array
$charset = range(",","|");
echo "Original Array <br>";
// I show the original array
print_r($charset);
// i put in a variable a random number from the set given
$random= array_rand($charset,1);
// using the unset function, i delete the chosen number previously stored in the variable
unset($charset[$random]);
echo "After delete the element <br>";
// Display Results
print_r($charset);
//here show the number that has been deleted
echo "<br>";
echo "The deleted char is " .$random;
?>
array_rand()andarray_splice()stackoverflow.com/a/17110980/2943403 Tailored demo: 3v4l.org/DBov6