in this code i try to unset first and last item of $status array
to unset but the last item that i tried place thier pointer in $end
not unset what can I do for this reason?
$item[$fieldneedle] = " node_os_disk_danger ";
$status = preg_split('/_/',$item[$fieldneedle]);
unset($status[0]);
$end = & end($status);
unset($end);
in this example i need os_disk
The Array pop() method is the simplest method used to remove the last element in an array. The pop() method returns the removed element from the original array.
The array_pop() function, which is used to remove the last element from an array, returns the removed element.
Use the splice() method to remove the last 2 elements from an array, e.g. arr. splice(arr. length - 2, 2) . The splice method will delete the 2 last elements from the array and return a new array containing the deleted elements.
Answer: Use the PHP array_pop() function You can use the PHP array_pop() function to remove an element or value from the end of an array. The array_pop() function also returns the last value of array.
array_shift($end); //removes first
array_pop($end); //removes last
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With