Code: Select all
<?xml version="1.0"?>
<cumbrianRD>
<Rrestaurant>
<Rname>Steve's Steak House</Rname>
<Raddress>Carlisle, Cumbria</Raddress>
<Rtel>05432 12345</Rtel>
<Rinfo>Steve's Steak House in Carlisle is one of the finest steak houses in the north of England, with their specialty: - award winning locally produced steaks. Located in the center of historic Carlisle, the grade 2 listed building was once a ... more</Rinfo>
<Rindex>1</Rindex>
</Rrestaurant>
<Rrestaurant>
<Rname>Fred's Fried Chicken</Rname>
<Raddress>Windermere, Cumbria</Raddress>
<Rtel>05432 543210</Rtel>
<Rinfo>Fred's Fried Chicken is located in the heart of the lake district. Established now for 15 years, they hae been bringing us Louisiana-style freid chicken like no other. For a pleasant evening of soul-food and soul music, be sure to ... more</Rinfo>
<Rindex>2</Rindex>
</Rrestaurant>
<Rrestaurant>
<Rname>The Laughing Tiger</Rname>
<Raddress>Carlisle, Cumbria</Raddress>
<Rtel>05432 543210</Rtel>
<Rinfo>For five years now The Laughing Tiger has been forging a reputation as one of the best Indian Restaurants in Cumbria, with a wide range of India's most delicious dishes ... more</Rinfo>
<Rindex>3</Rindex>
</Rrestaurant>Code: Select all
function object2array($object){return@json_decode(@json_encode($object),1);}
$xml = simplexml_load_file("places.xml");
$a = object2array($xml);Code: Select all
Array
(
[Rrestaurant] => Array
(
[0] => Array
(
[Rname] => Steve's Steak House
[Raddress] => Carlisle, Cumbria
[Rtel] => 05432 12345
[Rinfo] => Steve's Steak House in Carlisle is one of the finest steak houses in the north of England, with their specialty: - award winning locally produced steaks. Located in the center of historic Carlisle, the grade 2 listed building was once a ... more
[Rindex] => 1
)
[1] => Array
(
[Rname] => Fred's Fried Chicken
[Raddress] => Windermere, Cumbria
[Rtel] => 05432 543210
[Rinfo] => Fred's Fried Chicken is located in the heart of the lake district. Established now for 15 years, they hae been bringing us Louisiana-style freid chicken like no other. For a pleasant evening of soul-food and soul music, be sure to ... more
[Rindex] => 2
)
[2] => Array
(
[Rname] => The Laughing Tiger
[Raddress] => Carlisle, Cumbria
[Rtel] => 05432 543210
[Rinfo] => For five years now The Laughing Tiger has been forging a reputation as one of the best Indian Restaurants in Cumbria, with a wide range of India's most delicious dishes ... more
[Rindex] => 3
)
)
)
I am a bit of a n00b when it comes to this, but I have tried looking on php.net and adapting bits of code i see there. Does anyone know how I could do this?
My last attempt of some code:
Code: Select all
function object2array($object){return@json_decode(@json_encode($object),1);}
$xml = simplexml_load_file("places.xml");
$a = object2array($xml);
print_r($a); // prints the array successfully
$searchr = array_search ('a', $a, false); // Have tried characters, words, exact entire and case sensitive contents from the arrays
print_r ($searchr); // shows nothing




