Re: Parse arrays.
- From: ELINTPimp <smsiebe@xxxxxxxxx>
- Date: Mon, 30 Jul 2007 16:01:04 -0000
On Jul 30, 11:14 am, 1956col <prash.ma...@xxxxxxxxx> wrote:
hi all,
have a simple problem,
my array is :-
$c = array(
"2" => array(
"id" => "2",
"name" => "Sport",
"children" => array(
"4" => array(
"id" => "4",
"name" =>
"Archery",
"children" =>
"",
),
"5" => array(
"id" => "5",
"name" =>
"Badminton",
"children" =>
"",
),
),
),
);
and i want to convert this to
$options = array(
'Sports' =>array(
'3' => 'Archery',
'4' => 'Badminton',
),
);
Where 3 & 4 are the keys foe Archey & Badminton resp.
I am a newbie to PHP
getting so many problems solving this,
Any help appriciated.
something like this...
$options = array();
$kids = array();
foreach ($c as $cc) {
foreach ($cc['children'] as $key => $value) {
$k = $key - 1;
$kids[] = array($k => $value);
array_push($cc['name'] => $kids);
}
}
it depends on the bigger picture of your data and how it's formatted.
.
- Prev by Date: Re: Parse arrays.
- Next by Date: mysqli problem with stmt and binding parameters.
- Previous by thread: Re: Parse arrays.
- Next by thread: Re: Parse arrays.
- Index(es):
Relevant Pages
|