Home > Article > Backend Development > Two ways to delete array elements in php. Differences in usage of unset and array_splice
Results: Array ( [0] => a [2] => c [3] => d ) How can the missing elements be filled and the array re-indexed? The answer is array_splice(): Example:
Result: Array ( [0] => a [1] => c [2] => d ) Delete specific elements in the array (bbs.it-home.org Scripting School):
Delete empty arrays:
result: Array ( [a] => abc => bcd [c] => cde [d] => def ) Summary: If the array_splice() function is deleted, the index value of the array will also change. If the unset() function deletes it, the index value of the array will not change. |