Jump to content

Get data out of array without for each


Adamhumbug
Go to solution Solved by requinix,

Recommended Posts

I have an array.

Array
(
    [0] => Array
        (
            [id] => 19
            [section_id] => 4
            [sectionName] => x
            [itemName] => Item 1
            [GBP] => 0
            [USD] => 0
            [CAD] => 0
            [EUR] => 0
            [charge_by_id] => 1
            [consumable] => 1
            [cMIN] => 1
            [cMAX] => 499
            [cGBP] => 500
            [cUSD] => 750
            [cCAD] => 875
        )

    [1] => Array
        (
            [id] => 19
            [section_id] => 4
            [sectionName] => x
            [itemName] => Item 1
            [GBP] => 0
            [USD] => 0
            [CAD] => 0
            [EUR] => 0
            [charge_by_id] => 1
            [consumable] => 2
            [cMIN] => 500
            [cMAX] => 999
            [cGBP] => 1
            [cUSD] => 1.5
            [cCAD] => 1.75
        )

    [2] => Array
        (
            [id] => 19
            [section_id] => 4
            [sectionName] => x
            [itemName] => Item 1
            [GBP] => 0
            [USD] => 0
            [CAD] => 0
            [EUR] => 0
            [charge_by_id] => 1
            [consumable] => 3
            [cMIN] => 1000
            [cMAX] => 1999
            [cGBP] => 0.9
            [cUSD] => 1.35
            [cCAD] => 1.58
        )

    [3] => Array

i will foreach through most of it to get the data such as cMIN and cMAX on their own lines.

I need to get the item name out of this once, rather than once per line - the query means that the data will only be for one item so there is no chance that the item name will be different for any items in the array.

I have been trying to access the array data with

value='$rows[0][itemName]'>

but i am getting array to string conversion issue.

How do i get this out of the array without for eaching it?

Edited by Adamhumbug
Link to comment
Share on other sites

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.