Parse JSON object with PHP [duplicate] - php

This question already has an answer here:
How to extract and access data from JSON with PHP?
(1 answer)
Closed 5 years ago.
I've read every single question on StackOverflow on how to parse JSON with PHP but none of them are working with the JSON I have.
array(2) { ["status"]=> bool(true) ["currency"]=> array(30) { [0]=>
array(10) { ["currency"]=> string(7) "EUR/AUD" ["value"]=> string(6)
"1.4925" ["change"]=> string(7) "-0.0076" ["change_percent"]=>
string(8) "-0.50663" ["ask"]=> string(6) "1.4926" ["bid"]=> string(6)
"1.4923" ["daily_lowest"]=> string(6) "1.4873" ["daily_highest"]=>
string(6) "1.5016" ["date"]=> string(19) "2017-08-16 09:46:11"
["type"]=> string(8) "original" } [1]=> array(10) { ["currency"]=>
string(7) "EUR/CAD" ["value"]=> string(5) "1.494" ["change"]=>
string(7) "-0.0032" ["change_percent"]=> string(8) "-0.21373"
["ask"]=> string(5) "1.494" ["bid"]=> string(6) "1.4939"
["daily_lowest"]=> string(5) "1.489" ["daily_highest"]=> string(6)
"1.4986" ["date"]=> string(19) "2017-08-16 09:46:11" ["type"]=>
string(8) "original" } [2]=> array(10) { ["currency"]=> string(7)
"EUR/CHF" ["value"]=> string(6) "1.1434" ["change"]=> string(6)
"0.0024" ["change_percent"]=> string(7) "0.21034" ["ask"]=> string(6)
"1.1435" ["bid"]=> string(6) "1.1434" ["daily_lowest"]=> string(6)
"1.1402" ["daily_highest"]=> string(6) "1.1444" ["date"]=> string(19)
"2017-08-16 09:46:11" ["type"]=> string(8) "original" } [3]=>
array(10) { ["currency"]=> string(7) "EUR/GBP" ["value"]=> string(6)
"0.9099" ["change"]=> string(7) "-0.0019" ["change_percent"]=>
string(8) "-0.20838" ["ask"]=> string(4) "0.91" ["bid"]=> string(6)
"0.9099" ["daily_lowest"]=> string(6) "0.9083" ["daily_highest"]=>
string(6) "0.9144" ["date"]=> string(19) "2017-08-16 09:46:11"
["type"]=> string(8) "original" } [4]=> array(10) { ["currency"]=>
string(7) "EUR/ILS" ["type"]=> string(9) "converted" ["date"]=>
string(19) "2017-08-16 09:46:11" ["value"]=> string(7) "4.24323"
["change"]=> string(3) "0.0" ["change_percent"]=> string(3) "0.0"
["ask"]=> string(3) "0.0" ["bid"]=> string(3) "0.0" ["daily_lowest"]=>
string(3) "0.0" ["daily_highest"]=> string(3) "0.0" } [5]=> array(10)
{ ["currency"]=> string(7) "EUR/JPY" ["value"]=> string(8) "130.1145"
["change"]=> string(6) "0.2425" ["change_percent"]=> string(7)
"0.18672" ["ask"]=> string(7) "130.122" ["bid"]=> string(7) "130.107"
["daily_lowest"]=> string(7) "129.613" ["daily_highest"]=> string(7)
"130.405" ["date"]=> string(19) "2017-08-16 09:46:11" ["type"]=>
string(8) "original" } [6]=> array(10) { ["currency"]=> string(7)
"EUR/NZD" ["value"]=> string(6) "1.6182" ["change"]=> string(7)
"-0.0036" ["change_percent"]=> string(8) "-0.22198" ["ask"]=>
string(6) "1.6186" ["bid"]=> string(6) "1.6178" ["daily_lowest"]=>
string(6) "1.6138" ["daily_highest"]=> string(6) "1.6247" ["date"]=>
string(19) "2017-08-16 09:46:11" ["type"]=> string(8) "original" }
[7]=> array(10).............
I'm trying to output the value of each ["currency"] ["bid"] with this code:
foreach($result['currency'][0]['bid'] as $item) {
print $item['currency'][0]['bid'];
}
And tried 100 other variations, still getting errors like:
Warning: Illegal string offset 'currency' in getData.php on line 27
Warning: Illegal string offset 'value' in getData.php on line 27
Warning: Invalid argument supplied for foreach() in getData.php on line 27
Maybe there are online parser websites that can help with that? How do I solve this?

It seems to me like it should be.
foreach($result['currency']as $item) {
print $item['value'];
}
Because each currency is 0,1,2 and so on.
And in the item 0,1,2 there is the "value".

Related

oci_fetch_all equivalent for pdo?

I'm trying to get result from a postgres database with the fetchAll() function. But I have to get the same result from an Oracle DB and it doesn't work with the fetchAll() function.
With fetchall() i have an array with index numbers and each array represent a row from the db, but with oci_fetch_all each array have an array with the column name as index, and each array represent a column from the db and that's what I need
Postgres :
$stmt = $db->prepare($req);
$stmt->execute();
$res = $stmt->fetchAll();
output :
array(4) {
[0]=>
array(14) {
["PLU_PRESCRIPTION_S"]=>
string(18) "PLU_PRESCRIPTION_S"
[0]=>
string(18) "PLU_PRESCRIPTION_S"
["Critère"]=>
string(6) "02_PPA"
[1]=>
string(6) "02_PPA"
["type_prescription"]=>
string(6) "risque"
[2]=>
string(6) "risque"
["Aire parcelle (m²)"]=>
string(6) "298.62"
[3]=>
string(6) "298.62"
["Aire de lintersection (m²)"]=>
string(6) "298.62"
[4]=>
string(6) "298.62"
["%"]=>
string(6) "100.00"
[5]=>
string(6) "100.00"
["trig_comm"]=>
NULL
[6]=>
NULL
}
[1]=>
array(14) {
["PLU_PRESCRIPTION_S"]=>
string(18) "PLU_PRESCRIPTION_S"
[0]=>
string(18) "PLU_PRESCRIPTION_S"
["Critère"]=>
string(8) "04_zone1"
[1]=>
string(8) "04_zone1"
["type_prescription"]=>
string(3) "PDU"
[2]=>
string(3) "PDU"
["Aire parcelle (m²)"]=>
string(6) "298.62"
[3]=>
string(6) "298.62"
["Aire de lintersection (m²)"]=>
string(6) "298.62"
[4]=>
string(6) "298.62"
["%"]=>
string(6) "100.00"
[5]=>
string(6) "100.00"
["trig_comm"]=>
NULL
[6]=>
NULL
}
[2]=>
array(14) {
["PLU_PRESCRIPTION_S"]=>
string(18) "PLU_PRESCRIPTION_S"
[0]=>
string(18) "PLU_PRESCRIPTION_S"
["Critère"]=>
string(5) "07_MH"
[1]=>
string(5) "07_MH"
["type_prescription"]=>
string(10) "patrimoine"
[2]=>
string(10) "patrimoine"
["Aire parcelle (m²)"]=>
string(6) "298.62"
[3]=>
string(6) "298.62"
["Aire de lintersection (m²)"]=>
string(6) "298.62"
[4]=>
string(6) "298.62"
["%"]=>
string(6) "100.00"
[5]=>
string(6) "100.00"
["trig_comm"]=>
NULL
[6]=>
NULL
}
[3]=>
array(14) {
["PLU_PRESCRIPTION_S"]=>
string(18) "PLU_PRESCRIPTION_S"
[0]=>
string(18) "PLU_PRESCRIPTION_S"
["Critère"]=>
string(20) "18_OAP_communautaire"
[1]=>
string(20) "18_OAP_communautaire"
["type_prescription"]=>
string(3) "OAP"
[2]=>
string(3) "OAP"
["Aire parcelle (m²)"]=>
string(6) "298.62"
[3]=>
string(6) "298.62"
["Aire de lintersection (m²)"]=>
string(6) "298.62"
[4]=>
string(6) "298.62"
["%"]=>
string(6) "100.00"
[5]=>
string(6) "100.00"
["trig_comm"]=>
string(3) "CEN"
[6]=>
string(3) "CEN"
}
}
ORACLE :
if (oci_execute($ora_req)) {
// récupération des infos dans la base de donnée
$nrows = oci_fetch_all($ora_req, $res);
// Stockage des infos dans le tableau
array_push($arrPrescriptionS, $res);
}
OUTPUT :
array(0) { }
array(7) {
["'PLU_PRESCRIPTION_S'"]=>
array(4) {
[0]=>
string(18) "PLU_PRESCRIPTION_S"
[1]=>
string(18) "PLU_PRESCRIPTION_S"
[2]=>
string(18) "PLU_PRESCRIPTION_S"
[3]=>
string(18) "PLU_PRESCRIPTION_S"
}
["Critère"]=>
array(4) {
[0]=>
string(6) "02_PPA"
[1]=>
string(8) "04_zone1"
[2]=>
string(5) "07_MH"
[3]=>
string(20) "18_OAP_communautaire"
}
["TYPE_PRESCRIPTION"]=>
array(4) {
[0]=>
string(2) "02"
[1]=>
string(2) "04"
[2]=>
string(2) "07"
[3]=>
string(2) "18"
}
["Aire parcelle (m²)"]=>
array(4) {
[0]=>
string(6) "298,62"
[1]=>
string(6) "298,62"
[2]=>
string(6) "298,62"
[3]=>
string(6) "298,62"
}
["Aire de l'intersection (m²)"]=>
array(4) {
[0]=>
string(6) "298,62"
[1]=>
string(6) "298,62"
[2]=>
string(6) "298,62"
[3]=>
string(6) "298,62"
}
["%"]=>
array(4) {
[0]=>
string(3) "100"
[1]=>
string(3) "100"
[2]=>
string(3) "100"
[3]=>
string(3) "100"
}
["TRIG_COMM"]=>
array(4) {
[0]=>
NULL
[1]=>
NULL
[2]=>
NULL
[3]=>
string(3) "CEN"
}
}
thank's
This is not possible in PDO. PDO doesn't return results indexed by column names. This behaviour is not very intuitive when writing code, so it's best avoided. Use the normal fetch modes, which order results by rows.
If you need to write some shim for backwards compatibility you can do it yourself with nested loops.
$s = $pdo->query("SELECT * FROM bar");
$allByColumns = [];
foreach ($s->fetchAll(PDO::FETCH_ASSOC) as $index => $row) {
foreach ($row as $column => $value) {
$allByColumns[$column][$index] = $value;
}
}
var_dump($allByColumns);

Cant interact with PHP array

I'm turning grey headed over here..
Trying to interact with a array made from a csv file. When i echo parts of the array, it can be perfectly found. But when i try to use an array element in an IF sentence, it seems empty (its not empty).
Here is my code:
<?php
$filnavn="uploads/".$_COOKIE["f1l3nam3"];
$file = fopen($filnavn,"r");
$tael=0; //Used as a counter
while(! feof($file))
{
$resultat=fgetcsv($file,0,";");
if($resultat[19]!="DKK"){
$tael++;
}
}
echo $tael;
fclose($file);
?>
The result of this page is 0, it should be around 1320
var_dump($resultat[19]); gives me
string(7) "DKK"
string(7) "DKK"
string(7) "EUR"
string(7) "GBP"
string(7) "GBP"
string(7) "GBP"
string(7) "GBP"
string(7) "DKK"
string(7) "GBP"
string(7) "GBP"
string(7) "GBP"
string(7) "GBP"
string(7) "DKK"
string(7) "DKK"
string(7) "GBP"
string(7) "GBP"
string(7) "GBP"
string(7) "GBP"
string(7) "DKK"
string(7) "GBP"
string(7) "GBP"
string(7) "GBP"
string(7) "DKK"
string(7)
var_dump($resultat); gives me
array(31) {
[0]=> string(19) "246338756"
[1]=> string(41) "ContextType_Supplier"
[2]=> string(1) ""
[3]=> string(15) "0,00000"
[4]=> string(15) "0,00000"
[5]=> string(3) "0"
[6]=> string(3) "0"
[7]=> string(15) "0,00000"
[8]=> string(15) "0,00000"
[9]=> string(3) "0"
[10]=> string(3) "0"
[11]=> string(15) "0,00000"
[12]=> string(13) "311921"
[13]=> string(11) "17659"
[14]=> string(21) "08-05-2018"
[15]=> string(1) ""
[16]=> string(19) "246156901"
[17]=> string(17) "43534453"
[18]=> string(61) "Secret"
[19]=> string(7) "DKK"
}
Does anyone have any ideas?
Change your condition like below:-
if(strpos(trim($resultat[19]), "DKK") === false){
$tael++;
}
Or use
if(htmlentities($resultat[19]) != "DKK"){
$tael++;
}

PHP session saving array with POST values

First sorry for my English.
I have a weird problem using the php $_SESSION Object.
I spent 2 days without find the solution.
I am triying to save a multidimensional array that stores some post values.
I create an array with this values and then i create a multidimensional array containing this arrays.
Page 1 (setvalues in multi array ans save in session)-> GET -> Page 2 read the session.
My code Page 1:
First, save the post values into a object property and validate them.
public function validateData(){
$this->nombres=$_POST["nombre"];
$this->imp_nombres=$_POST["imp_nombre"];
$this->numeros=$_POST["numero"];
$this->imp_numeros=$_POST["imp_numero"];
$this->tallas=$_POST["talla"];
$this->cantidades=$_POST["cantidad"];
$this->productos=$_POST["products"];
$this->equipos=$_POST["equipo"];
if(WSI_Funtions::compareSizes($this->nombres,$this->imp_nombres,$this->numeros,$this->imp_numeros,$this->tallas,$this->cantidades,$this->productos,$this->equipos))
{
$this->isValidModel=true;
$this->saveProductsValues();
}
else{
$this->isValidModel=false;
$this->errorMessage="Los datos no son correctos. Los parametros no coinciden";
}
}
If data is ok, I save those values:
public function saveProductsValues()
{
$this->productsValues=array();
$this->productsValues["names"]=$this->nombres;
$this->productsValues["imp_nombres"]=$this->imp_nombres;
$this->productsValues["numeros"]=$this->numeros;
$this->productsValues["imp_numeros"]=$this->imp_numeros;
$this->productsValues["tallas"]=$this->tallas;
$this->productsValues["cantidades"]=$this->cantidades;
$this->productsValues["productos"]=$this->productos;
$this->productsValues["equipos"]=$this->equipos;
}
Then I save it in a session :
public function saveSessionValues()
{
$_SESSION['customer'] = $this->customerObject;
$_SESSION['productsValues'] =$this->productsValues;
echo var_dump($_SESSION['productsValues']);
}
The saveSessionValues echo print this:
array(8) { ["names"]=> array(12) { [0]=> string(0) "" [1]=> string(12) "ÁNGEL HDEZ." [2]=> string(11) "VUJASINOVIC" [3]=> string(4) "ABIA" [4]=> string(10) "MUTAKABBIR" [5]=> string(8) "PETROVIC" [6]=> string(5) "DOBOS" [7]=> string(4) "HOMS" [8]=> string(6) "CASTRO" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" } ["imp_nombres"]=> array(12) { [0]=> string(0) "" [1]=> string(1) "1" [2]=> string(1) "1" [3]=> string(1) "1" [4]=> string(1) "1" [5]=> string(1) "1" [6]=> string(1) "1" [7]=> string(1) "1" [8]=> string(1) "1" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" } ["numeros"]=> array(12) { [0]=> string(1) "7" [1]=> string(1) "8" [2]=> string(1) "9" [3]=> string(0) "" [4]=> string(2) "11" [5]=> string(2) "12" [6]=> string(2) "18" [7]=> string(2) "19" [8]=> string(2) "22" [9]=> string(1) "5" [10]=> string(2) "33" [11]=> string(0) "" } ["imp_numeros"]=> array(12) { [0]=> string(1) "1" [1]=> string(1) "1" [2]=> string(1) "1" [3]=> string(0) "" [4]=> string(1) "1" [5]=> string(1) "1" [6]=> string(1) "1" [7]=> string(1) "1" [8]=> string(1) "1" [9]=> string(1) "1" [10]=> string(1) "1" [11]=> string(0) "" } ["tallas"]=> array(12) { [0]=> string(4) "XXXL" [1]=> string(3) "XXL" [2]=> string(2) "XL" [3]=> string(3) "XXL" [4]=> string(3) "XXL" [5]=> string(3) "XXL" [6]=> string(4) "XXXL" [7]=> string(3) "XXL" [8]=> string(2) "XL" [9]=> string(4) "XXXL" [10]=> string(2) "XL" [11]=> string(3) "XXL" } ["cantidades"]=> array(12) { [0]=> string(1) "1" [1]=> string(1) "1" [2]=> string(1) "1" [3]=> string(1) "1" [4]=> string(3) "145" [5]=> string(1) "1" [6]=> string(1) "1" [7]=> string(1) "1" [8]=> string(1) "1" [9]=> string(1) "1" [10]=> string(1) "1" [11]=> string(1) "1" } ["productos"]=> array(12) { [0]=> string(3) "109" [1]=> string(3) "109" [2]=> string(3) "109" [3]=> string(3) "109" [4]=> string(3) "109" [5]=> string(3) "109" [6]=> string(3) "109" [7]=> string(3) "109" [8]=> string(3) "109" [9]=> string(3) "109" [10]=> string(3) "109" [11]=> string(3) "109" } ["equipos"]=> array(12) { [0]=> string(7) "LEB ORO" [1]=> string(7) "LEB ORO" [2]=> string(7) "LEB ORO" [3]=> string(7) "LEB ORO" [4]=> string(7) "LEB ORO" [5]=> string(7) "LEB ORO" [6]=> string(12) "ES TALLA 4XL" [7]=> string(7) "LEB ORO" [8]=> string(7) "LEB ORO" [9]=> string(12) "ES TALLA 4XL" [10]=> string(7) "LEB ORO" [11]=> string(7) "LEB ORO" } }
My code Page 2 (php tags ommitted):
if (!isset($_SESSION)) { session_start(); }
echo var_dump($_SESSION['productsValues']);
This echo print the next value:
array(8) { ["names"]=> NULL ["imp_nombres"]=> NULL ["numeros"]=> NULL ["imp_numeros"]=> NULL ["tallas"]=> NULL ["cantidades"]=> NULL ["productos"]=> NULL ["equipos"]=> NULL }
The first level array exists, because the subarrays keys are printed, but all the second level arrays are NULL..
Maybe is for use the $_POST value??
I had try to encode the values of the $_POST object, saving only a json string instead of saving a object with the same result, the first nodes in the JSON are the keys of the arrays but the values are "NULL"
Any help please??
Thanks!!
You are over writing the values. Try with -
$_SESSION['productsValues'][] = $this->productsValues;

How to read var_dump in order to know how to load its variable contents in to an array with a foreach?

Here is a sample var_dump. Now, how do I know how to construct a foreach from it to load any particular word or fragment in to an array?
object(stdClass)#1 (2)
{
["noun"]=>
object(stdClass)#2 (1)
{
["syn"]=> array(24)
{
[0]=> string(12) "domestic dog"
[1]=> string(16) "Canis familiaris"
[2]=> string(5) "frump"
[3]=> string(3) "cad"
[4]=> string(7) "bounder"
[5]=> string(10) "blackguard"
[6]=> string(5) "hound"
[7]=> string(4) "heel"
[8]=> string(5) "frank"
[9]=> string(11) "frankfurter"
[10]=> string(6) "hotdog"
[11]=> string(7) "hot dog"
[12]=> string(6) "wiener"
[13]=> string(11) "wienerwurst"
[14]=> string(6) "weenie"
[15]=> string(4) "pawl"
[16]=> string(6) "detent"
[17]=> string(5) "click"
[18]=> string(7) "andiron"
[19]=> string(7) "firedog"
[20]=> string(8) "dog-iron"
[21]=> string(8) "blighter"
[22]=> string(5) "canid"
[23]=> string(6) "canine"
[24]=> string(5) "catch"
}
}
}
Before we can decipher it, we have to format it.
Tobias Kun's answer shows a very good way to format the var_dump output so you can read it.
object(stdClass)#1 (2)
{
["noun"]=>
object(stdClass)#2 (1)
{
["syn"]=> array(24)
{
[0]=> string(12) "domestic dog"
[1]=> string(16) "Canis familiaris"
[2]=> string(5) "frump"
[3]=> string(3) "cad"
[4]=> string(7) "bounder"
[5]=> string(10) "blackguard"
[6]=> string(5) "hound"
[7]=> string(4) "heel"
[8]=> string(5) "frank"
[9]=> string(11) "frankfurter"
[10]=> string(6) "hotdog"
[11]=> string(7) "hot dog"
[12]=> string(6) "wiener"
[13]=> string(11) "wienerwurst"
[14]=> string(6) "weenie"
[15]=> string(4) "pawl"
[16]=> string(6) "detent"
[17]=> string(5) "click"
[18]=> string(7) "andiron"
[19]=> string(7) "firedog"
[20]=> string(8) "dog-iron"
[21]=> string(8) "blighter"
[22]=> string(5) "canid"
[23]=> string(6) "canine"
[24]=> string(5) "catch"
}
}
}
You have a stdClass object with a property called ,"noun". noun is an abject with a property called "syn", which is an array of strings.
Suppose we call the object $object. Then we can access the array like:
echo $object->noun->syn[23];
which gives us canine. So a loop might look like:
foreach($data->noun->syn as $value) {
echo $value . "<br>\n";
}
First of all you should really increase the quality of your questions. The code is not formatted at all.
If you use echo "<pre>" . print_r($your_data_object_or_array,1) . "</pre>" your data will be formatted fine.
If i understand you right this should help you:
foreach($data['noun']['syn'] as $value) {
//with this you loop through all your words in "syn" e.g. domestic, "Canis familiaris etc."
echo $value . "<br>";
}
//Ouput:
domestic
Canis familiaris
frump
cad
etc ...

Loaded an XML file response, how do I get the data out of it now?

I received this XML data and var_dumped it.
How do I use this now and fetch one of the records from inside? like $this->{product}->name etc.?
object(SimpleXMLElement)#189 (1) { ["products"]=> object(SimpleXMLElement)#188 (2) { ["#attributes"]=> array(3) { ["total-matched"]=> string(1) "3" ["records-returned"]=> string(1) "3" ["page-number"]=> string(1) "1" } ["product"]=> array(3) { [0]=> object(SimpleXMLElement)#206 (19) { ["ad-id"]=> string(8) "10581256" ["advertiser-id"]=> string(7) "2466656" ["advertiser-name"]=> string(18) "Everydaysource.com" ["advertiser-category"]=> string(21) "MP3 Accessories>Cases" ["buy-url"]=> string(245) "http://www.kqzyfj.com/click-4107027-10581256?url=http%3A%2F%2Fwww.everydaysource.com%2Fproduct%2Fsnap-on-case-compatible-with-apple-ipod-touch-4th-gen-colorful-zebra%2Fdapptoucco62%3Fesaffcojudtf120626%3Daf%2Bcj%2Bdapptoucco62&cjsku=DAPPTOUCCO62" ["catalog-id"]=> string(8) "cjo:2691" ["currency"]=> string(3) "USD" ["description"]=> string(57) "Compatible With Apple®:iPod touch® 4th Generation" ["image-url"]=> string(73) "http://cdn1.everydaysource.com/cdn2/110207/fb/28/d2/dapptoucco62_1_es.jpg" ["in-stock"]=> object(SimpleXMLElement)#98 (0) { } ["isbn"]=> object(SimpleXMLElement)#99 (0) { } ["manufacturer-name"]=> string(14) "EverydaySource" ["manufacturer-sku"]=> string(12) "DAPPTOUCCO62" ["name"]=> string(69) "Snap-on Case Compatible with Apple iPod Touch 4th Gen,Colorful Zebra" ["price"]=> string(4) "8.99" ["retail-price"]=> string(3) "0.0" ["sale-price"]=> string(3) "0.0" ["sku"]=> string(12) "DAPPTOUCCO62" ["upc"]=> string(12) "628569324674" } [1]=> object(SimpleXMLElement)#100 (19) { ["ad-id"]=> string(8) "10402409" ["advertiser-id"]=> string(7) "1636472" ["advertiser-name"]=> string(8) "Eforcity" ["advertiser-category"]=> string(21) "MP3 Accessories>Cases" ["buy-url"]=> string(233) "http://www.jdoqocy.com/click-4107027-10402409?url=http%3A%2F%2Fwww.eforcity.com%2Fsnap-on-case-compatible-with-apple-ipod-touch-4th-gen-colorful-zebra-dapptoucco62.html%3Fefaffcojudtf120626%3Daf%2Bcj%2Bdapptoucco62&cjsku=DAPPTOUCCO62" ["catalog-id"]=> string(8) "cjo:1136" ["currency"]=> string(3) "USD" ["description"]=> string(57) "Compatible With Apple®:iPod touch® 4th Generation" ["image-url"]=> string(68) "http://cdn1.eforcity.com/cdn2/110101/41/86/a3/dapptoucco62_1_efc.jpg" ["in-stock"]=> object(SimpleXMLElement)#99 (0) { } ["isbn"]=> object(SimpleXMLElement)#98 (0) { } ["manufacturer-name"]=> string(8) "eForCity" ["manufacturer-sku"]=> string(12) "DAPPTOUCCO62" ["name"]=> string(69) "Snap-on Case Compatible with Apple iPod Touch 4th Gen,Colorful Zebra" ["price"]=> string(4) "7.99" ["retail-price"]=> string(3) "0.0" ["sale-price"]=> string(3) "0.0" ["sku"]=> string(12) "DAPPTOUCCO62" ["upc"]=> string(12) "628569324674" } [2]=> object(SimpleXMLElement)#101 (19) { ["ad-id"]=> string(8) "10581247" ["advertiser-id"]=> string(7) "2466659" ["advertiser-name"]=> string(15) "iTrimming Corp." ["advertiser-category"]=> string(21) "MP3 Accessories>Cases" ["buy-url"]=> string(165) "http://www.dpbolvw.net/click-4107027-10581247?url=http%3A%2F%2Fwww.itrimming.com%2Fdapptoucco62.html%3Fitaffcojudtf120626%3Daf%2Bcj%2Bdapptoucco62&cjsku=DAPPTOUCCO62" ["catalog-id"]=> string(8) "cjo:2690" ["currency"]=> string(3) "USD" ["description"]=> string(57) "Compatible With Apple®:iPod touch® 4th Generation" ["image-url"]=> string(68) "http://cdn1.itrimming.com/cdn2/110301/c9/cc/33/dapptoucco62_1_it.jpg" ["in-stock"]=> object(SimpleXMLElement)#98 (0) { } ["isbn"]=> object(SimpleXMLElement)#99 (0) { } ["manufacturer-name"]=> string(9) "iTrimming" ["manufacturer-sku"]=> string(12) "DAPPTOUCCO62" ["name"]=> string(69) "Snap-on Case Compatible with Apple iPod Touch 4th Gen,Colorful Zebra" ["price"]=> string(4) "7.59" ["retail-price"]=> string(3) "0.0" ["sale-price"]=> string(3) "0.0" ["sku"]=> string(12) "DAPPTOUCCO62" ["upc"]=> string(12) "628569324674" } } } }
Pastebin of the same : http://pastebin.com/XYN8ysEG
Thank you!
** Edit **
Here is the raw data
object(SimpleXMLElement)#189 (1) {
["products"]=>
object(SimpleXMLElement)#188 (2) {
["#attributes"]=>
array(3) {
["total-matched"]=>
string(1) "4"
["records-returned"]=>
string(1) "4"
["page-number"]=>
string(1) "1"
}
["product"]=>
array(4) {
[0]=>
object(SimpleXMLElement)#206 (19) {
["ad-id"]=>
string(8) "10450940"
["advertiser-id"]=>
string(7) "1427863"
["advertiser-name"]=>
string(12) "Bookbyte.com"
["advertiser-category"]=>
string(5) "Books"
["buy-url"]=>
string(151) "http://www.anrdoezrs.net/click-4107027-10450940?url=http%3A%2F%2Fwww.bookbyte.com%2Fproduct.aspx%3Fisbn%3D1576751740%26noredirect%3Dtrue&cjsku=13671976"
["catalog-id"]=>
string(8) "cjo:1574"
["currency"]=>
string(3) "USD"
["description"]=>
string(34) "This book is in Like New condition"
["image-url"]=>
object(SimpleXMLElement)#77 (0) {
}
["in-stock"]=>
object(SimpleXMLElement)#74 (0) {
}
["isbn"]=>
string(10) "1576751740"
["manufacturer-name"]=>
object(SimpleXMLElement)#75 (0) {
}
["manufacturer-sku"]=>
object(SimpleXMLElement)#72 (0) {
}
["name"]=>
string(53) "Leadership and Self Deception: Getting Out of the Box"
["price"]=>
string(4) "13.5"
["retail-price"]=>
string(5) "14.95"
["sale-price"]=>
string(3) "0.0"
["sku"]=>
string(8) "13671976"
["upc"]=>
object(SimpleXMLElement)#73 (0) {
}
}
[1]=>
object(SimpleXMLElement)#78 (19) {
["ad-id"]=>
string(8) "10450940"
["advertiser-id"]=>
string(7) "1427863"
["advertiser-name"]=>
string(12) "Bookbyte.com"
["advertiser-category"]=>
string(5) "Books"
["buy-url"]=>
string(148) "http://www.jdoqocy.com/click-4107027-10450940?url=http%3A%2F%2Fwww.bookbyte.com%2Fproduct.aspx%3Fisbn%3D1576751740%26noredirect%3Dtrue&cjsku=1084348"
["catalog-id"]=>
string(8) "cjo:1574"
["currency"]=>
string(3) "USD"
["description"]=>
string(41) "This book is in New - Excellent condition"
["image-url"]=>
object(SimpleXMLElement)#73 (0) {
}
["in-stock"]=>
object(SimpleXMLElement)#72 (0) {
}
["isbn"]=>
string(10) "1576751740"
["manufacturer-name"]=>
object(SimpleXMLElement)#75 (0) {
}
["manufacturer-sku"]=>
object(SimpleXMLElement)#74 (0) {
}
["name"]=>
string(53) "Leadership and Self Deception: Getting Out of the Box"
["price"]=>
string(5) "11.21"
["retail-price"]=>
string(5) "14.95"
["sale-price"]=>
string(3) "0.0"
["sku"]=>
string(7) "1084348"
["upc"]=>
object(SimpleXMLElement)#77 (0) {
}
}
[2]=>
object(SimpleXMLElement)#79 (19) {
["ad-id"]=>
string(8) "10450940"
["advertiser-id"]=>
string(7) "1427863"
["advertiser-name"]=>
string(12) "Bookbyte.com"
["advertiser-category"]=>
string(5) "Books"
["buy-url"]=>
string(148) "http://www.kqzyfj.com/click-4107027-10450940?url=http%3A%2F%2Fwww.bookbyte.com%2Fproduct.aspx%3Fisbn%3D1576751740%26noredirect%3Dtrue&cjsku=12530742"
["catalog-id"]=>
string(8) "cjo:1574"
["currency"]=>
string(3) "USD"
["description"]=>
string(34) "This book is in Like New condition"
["image-url"]=>
object(SimpleXMLElement)#77 (0) {
}
["in-stock"]=>
object(SimpleXMLElement)#74 (0) {
}
["isbn"]=>
string(10) "1576751740"
["manufacturer-name"]=>
object(SimpleXMLElement)#75 (0) {
}
["manufacturer-sku"]=>
object(SimpleXMLElement)#72 (0) {
}
["name"]=>
string(53) "Leadership and Self Deception: Getting Out of the Box"
["price"]=>
string(5) "29.25"
["retail-price"]=>
string(5) "14.95"
["sale-price"]=>
string(3) "0.0"
["sku"]=>
string(8) "12530742"
["upc"]=>
object(SimpleXMLElement)#73 (0) {
}
}
[3]=>
object(SimpleXMLElement)#76 (19) {
["ad-id"]=>
string(8) "10586024"
["advertiser-id"]=>
string(7) "2172304"
["advertiser-name"]=>
string(5) "Chegg"
["advertiser-category"]=>
string(45) "Media > Books > Non-Fiction > Education Books"
["buy-url"]=>
string(116) "http://www.dpbolvw.net/click-4107027-10586024?url=http%3A%2F%2Fwww.chegg.com%2Fdetails%2F1576751740&cjsku=1576751740"
["catalog-id"]=>
string(8) "cjo:2718"
["currency"]=>
string(3) "USD"
["description"]=>
string(584) "The disease of self-deception (acting in ways contrary to what one knows is right) underlies all leadership problems in today's organizations, according to the premise of this work. However well intentioned they may be, leaders who deceive themselves always end up undermining their own performance.This straightforward book explains how leaders can discover their own self-deceptions and learn how to escape destructive patterns. The authors demonstrate that breaking out of these patterns leads to improved teamwork, commitment, trust, communication, motivation, and leadership."
["image-url"]=>
string(53) "http://c.chegg.com/covers2/10000/15246_1307127219.jpg"
["in-stock"]=>
object(SimpleXMLElement)#73 (0) {
}
["isbn"]=>
string(10) "1576751740"
["manufacturer-name"]=>
string(9) "chegg.com"
["manufacturer-sku"]=>
object(SimpleXMLElement)#72 (0) {
}
["name"]=>
string(29) "Leadership and Self-Deception"
["price"]=>
string(4) "9.99"
["retail-price"]=>
string(5) "15.95"
["sale-price"]=>
string(3) "0.0"
["sku"]=>
string(10) "1576751740"
["upc"]=>
string(13) "9781576751749"
}
}
}
}
they are Objects (SimpleXMLElement)
$result->products->product[0]->name

Categories