Skip to content

Instantly share code, notes, and snippets.

@BillKeenan
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BillKeenan/ed3aeb38293399e09692 to your computer and use it in GitHub Desktop.
Save BillKeenan/ed3aeb38293399e09692 to your computer and use it in GitHub Desktop.
<?php
$notavector =['one','two','three'];
print_r($notavector);
unset($notavector[1]);
//missing a key!
print_r($notavector);
//so now this will blow up
for ($i=0;$i<count($notavector);$i++){
print($notavector[$i]."\r\n");
}
/*
and now the output:
Array
(
[0] => one
[1] => two
[2] => three
)
Array
(
[0] => one
[2] => three
)
one
PHP Notice: Undefined offset: 1 in /private/tmp/proc.php on line 14
Notice: Undefined offset: 1 in /private/tmp/proc.php on line 14
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment