1

Just starting with php and sorry if this is a newbie question but i'm having problems parsing a array.

I get this value(output of print_r($result);):

Array ( 
  [0] => stdClass Object ( 
       [Master_companyname] => Royal Bank of Canada 
       [ticker] => ry-t 
       [base_table] => Master 
       [base_field] => ticker 
       [set] => 
           [rendered] =>
              Companyname:
              Ticker:
              Companyname:
       [finder_element_1_Master_companyname] => Royal Bank of Canada 
       [field_names] => Array ( 
            [1] => finder_element_1_Master_companyname 
            ) 
       ) 
   )

I want to extract only ry-t but not sure how. Here's what I tried

$result1 = implode('=>', $result);
print_r($result);

and

print (float)substr($result1, strpos($result1, "=")+1);

I studied a bit of java and python and I was trying to apply the same logic of converting it to a string and then splitting the text by a delimiting(in this case I thought "=>").

hakre
  • 193,403
  • 52
  • 435
  • 836
Lostsoul
  • 25,013
  • 48
  • 144
  • 239

1 Answers1

3

You have to subscript the array member, and then the ticker property.

echo $result[0]->ticker;
alex
  • 479,566
  • 201
  • 878
  • 984
  • omg thank you so much. I can't believe its so simple. I have probably written like 50 lines of code trying to parse this file. Thank you so much Alex. – Lostsoul May 25 '11 at 05:24