search - PHP find element value in multi-dimension session array -


i have below multi-dimension session array store cart items, want search whether price in cart list contain price 0.00, if yes, want return true , url redirection.

array (     [0] => array         (             [p_name] => product 01             [p_id] => 123             [p_price] => 0.00             [p_alt-variation-1] => blue             [p_alt-variation-2] => l             [p_qty] => 1         )      [1] => array         (             [p_name] => product 02             [p_id] => 124             [p_price] => 13.00             [p_qty] => 1         )      [2] => array         (             [p_name] => product 03             [p_id] => 125             [p_price] => 99.00             [p_qty] => 2         )  ) 

i've try :

$key = array_search(0.00, array_column($_session['products'], 'p_price')); echo $key;  if($key === true){     //redirect url } 

it end displayed 0, means?

you should start beginning: make work simple foreach (that efficient way):

foreach ($_session['products'] $key => $product) {     if ($product['p_price'] === '0.00') {         // want     } } 

when want use function, read related page in php manual, explains parameters , returns function.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -