Jump to content

PHP Array Help


Recommended Posts

Hey guys,


I have a php array that looks like this:

    [opportunity_items] => Array
            [0] => Array
                    [id] => 2783
                    [opportunity_id] => 92
                    [item_id] => 
                    [item_type] => 
                    [opportunity_item_type] => 0
                    [opportunity_item_type_name] => Group
                    [name] => Strobes
                    [transaction_type] => 
                    [transaction_type_name] => 
                    [accessory_inclusion_type] => 
                    [accessory_inclusion_type_name] => 
                    [accessory_mode] => 

The array goes on for ages, but I have only shown the bits I need. I want to create a new array that just contains the [id] key.


I can get the first value by doing this:

echo $array["opportunity_items"]["0"]["id"];

But I somehow I need to loop through this to get all of the rest of the values.





Edited by AJLX
Link to comment
Share on other sites

Ah yes! The code I used above with print_r was just to prove that the result was correct. The code I used to actually build the array looked like this:

$assets = array();

foreach ($obj as $key) {
	foreach ($key as $id) {
		$assets[] = ($id['id']);		


Link to comment
Share on other sites

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.

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.