<?php
$frndof=array("name"=>'frnd_of_xyx',"id"=>001,"url"=>'tutorboy.com/frnd_of_xyx',
"address"=>array("city"=>'NewZend',"zip"=>'100450'));
$frndof1=array("name"=>'frnd_of_xyx1',"id"=>0011,"url"=>'tutorboy.com/frnd_of_xyx1',
"frnds"=>$frndof,"address"=>array("city"=>'NewZend1',"zip"=>'100422'));
$a = array( array("name"=>'xyx',"id"=>001,"url"=>'tutorboy.com/xyx',
"address"=>array("city"=>'cochin',"zip"=>'100450')),
array("name"=>'abc',"id"=>001,"url"=>'tutorboy.com/abc',"frnds"=>$frndof1,"address"=>array("city"=>'Bosco',"zip"=>'100450')),
array("name"=>'EFG',"id"=>001,"url"=>'tutorboy.com/EFG',"address"=>array("city"=>'NY',"zip"=>'100450'))
);
?>
<pre>
<?
print_r($a);
?>
Array
(
[0] => Array
(
[name] => xyx
[id] => 1
[url] =>example.com/xyx
[address] => Array
(
[city] => cochin
[zip] => 100450
)
)
[1] => Array
(
[name] => abc
[id] => 1
[url] =>example.com/abc
[frnds] => Array
(
[name] => frnd_of_xyx1
[id] => 9
[url] =>example.com/frnd_of_xyx1
[frnds] => Array
(
[name] => frnd_of_xyx
[id] => 1
[url] =>example.com/frnd_of_xyx
[address] => Array
(
[city] => NewZend
[zip] => 100450
)
)
[address] => Array
(
[city] => NewZend1
[zip] => 100422
)
)
[address] => Array
(
[city] => Bosco
[zip] => 100450
)
)
[2] => Array
(
[name] => EFG
[id] => 1
[url] =>example.com/EFG
[address] => Array
(
[city] => NY
[zip] => 100450
)
)
)
This is my array. :-)
I need a to replace the following array array_fig(1) with
[frnds] => Array
(
[name] => frnd_of_xyx
[id] => 1
[url] =>example.com/frnd_of_xyx /* this is the unique key */
[address] => Array
(
[city] => NewZend
[zip] => 100450
)
)
array_fig(2)
[frnds] => Array
(
[name] => frnd_of_xyx
[id] => 1
[url] =>example.com/frnd_of_xyx /* this is the unique key */
[address] => Array
(
[city] => NewZend_neww
[zip] => 1004501212122
)
)
The Key URL is the Unique key. [frnds] array need to be repalce with new [frnds] array. ie How to find the parent key or array key with " [url] " key as the unique.
Note:this array is used for the xml generation so, these are the elements and arrtibutes, so inner elements concepts