Jump to content

Recommended Posts

$matches is an array as follows:

Array
(
    [0] => Array
        (
            [0] => sku234567 the price equals $33.00
            [1] => sku999888 the price equals $82.44
        )

    [1] => Array
        (
            [0] => 234567
            [1] => 999888
        )

    [2] => Array
        (
            [0] => $33.00
            [1] => $82.44
        )

)

Using PHP, how do I end up with this:
234567 is $33.00
999888 is $82.44

I have tried just about everything, like echo "$matches[0] is $matches[2]" and $matches[1][1][2] and foreach loops.....
I know I can access $matches[1] using a foreach loop, but then how do I access its corresponding value from $matches[2] ?

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/313664-getting-2-array-values/
Share on other sites

In case you have control over how $matches is formatted, you could make this easier on yourself by changing the array to something like this:

Array
(
    [0] => Array
        (
            [sku]   => 234567
            [price] => $33.00
        )

    [1] => Array
        (
            [sku]   => 999888            
            [price] => $82.44
        )

)

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.