Jump to content

Array manipulation


CardBoy
 Share

Recommended Posts

Hi

 

I  have an array declared as



static $array = array(
'a0' => array(
'b1' => array(
'c0' => 5,
'c1' => 'hi',
),
 
'b2' => array(
'd0' => 5,
'd1' => 'hi',
), ),
'a2' => 10,
);


 

What I need to do is  to loop over the array and extract a set of arrays  such that these new arrays have an element removed, but leaving the original array in tact.

So the first array in the set would remove 'a0' and looks like



static $array = array(
'a2' => 10,
);


The second would remove [a0][b1] and looks like



static $array = array(
'a0' => array(
'b2' => array(
'd0' => 5,
'd1' => 'hi',
), ),
'a2' => 10,
);


etc

 

Please can anyone help?

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.