Voting

: seven minus six?
(Example: nine)

The Note You're Voting On

carl at thep dot lu dot se
21 years ago
To unset elements in an array if you know the keys but not the values, you can do:

<?php
$a
= array("foo", "bar", "baz", "quux");
$b = array(1, 3); // Elements to get rid of

foreach($b as $e)
unset(
$a[$e]);
?>

Of course this makes most sense if $b has many elements or is dynamically generated.

<< Back to user notes page

To Top