in PHP find if a value of an inner array exists, then if found, delete the array -


i have simple 2 dimensional array. i'm trying write function finds if value exists in 1 of inner arrays. not hard. problem need delete entire inner array once found. that's i'm having trouble with. seems impossible using foreach loops.

anyway, here array. thanks!

$booksincart = array (array ('bookid' => 344, 'quantity' => 1),               array ('bookid' => 54, 'quantity' => 1),               array ('bookid' => 172, 'quantity' => 2),                array ('bookid' => 3, 'quantity' => 1) ); 

use foreach loop key , value. use key unset() sub-array...

foreach ($booksincart $key => $sub) {     if ($sub['bookid'] == 172) {         unset($booksincart[$key]);     } } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -