Skip to content

Instantly share code, notes, and snippets.

@bbatsche
Last active August 29, 2015 13:56
Show Gist options
  • Save bbatsche/8937875 to your computer and use it in GitHub Desktop.
Save bbatsche/8937875 to your computer and use it in GitHub Desktop.
Snippet on how to reset the array keys
<?php
// ...
} elseif ($input == 'R') {
// Remove which item?
echo 'Enter item number to remove: ';
// Get array key
$key = trim(fgets(STDIN));
while ($key < count($items)) {
$items[$key - 1] = $items[$key];
$key++;
}
// Remove from array
unset($items[$key - 1]);
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment