If Key Value pair exists in multidimensional array.. How to?

Posted by Daniel White on Stack Overflow See other posts from Stack Overflow or by Daniel White
Published on 2012-11-24T22:37:06Z Indexed on 2012/11/24 23:04 UTC
Read the original article Hit count: 182

Filed under:
|
|

I have a codeigniter shopping cart going and its "cart" array is the following:

Array (
[a87ff679a2f3e71d9181a67b7542122c] => Array
    (
        [rowid] => a87ff679a2f3e71d9181a67b7542122c
        [id] => 4
        [qty] => 1
        [price] => 12.95
        [name] => Maroon Choir Stole
        [image] => 2353463627maroon_3.jpg
        [custprod] => 0
        [subtotal] => 12.95
    )

[8f14e45fceea167a5a36dedd4bea2543] => Array
    (
        [rowid] => 8f14e45fceea167a5a36dedd4bea2543
        [id] => 7
        [qty] => 1
        [price] => 12.95
        [name] => Shiny Red Choir Stole
        [image] => 2899638984red_vstole_1.jpg
        [custprod] => 0
        [subtotal] => 12.95
    )

[eccbc87e4b5ce2fe28308fd9f2a7baf3] => Array
    (
        [rowid] => eccbc87e4b5ce2fe28308fd9f2a7baf3
        [id] => 3
        [qty] => 1
        [price] => 14.95
        [name] => Royal Blue Choir Stole
        [image] => 1270984005royal_vstole.jpg
        [custprod] => 1
        [subtotal] => 14.95
    )

)

My goal is to loop through this multidimensional array some how and if ANY product with the key value pair "custprod == 1" exists, then my checkout page will display one thing, and if no custom products are in the cart it displays another thing. Any help is appreciated. Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about codeigniter