Created
September 3, 2021 19:08
-
-
Save SparK-Cruz/106498240f8cd567fa3d0089f4ef88f7 to your computer and use it in GitHub Desktop.
Ruby's array#delete for PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function array_delete(&$array, $key) { | |
if (!isset($array[$key])) { | |
return null; | |
} | |
$value = $array[$key]; | |
unset($array[$key]); | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment