Skip to content

Instantly share code, notes, and snippets.

@SparK-Cruz
Created September 3, 2021 19:08
Show Gist options
  • Save SparK-Cruz/106498240f8cd567fa3d0089f4ef88f7 to your computer and use it in GitHub Desktop.
Save SparK-Cruz/106498240f8cd567fa3d0089f4ef88f7 to your computer and use it in GitHub Desktop.
Ruby's array#delete for PHP
<?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