1

I am pretty new in php. I am trying to print a data from an array.I have googled for it but can't find any solution yet.

Array ( [0] => stdClass Object ( [id] => 2  [university_name] => UNIV_NAME [university_id] => 1 [year] => 2010 )

Here i want to print just the "UNIV_NAME ".How can i get UNIV_NAME as output.

Developer
  • 385
  • 1
  • 3
  • 18

2 Answers2

3
echo $array[0]->university_name
Tobias
  • 7,723
  • 1
  • 27
  • 44
0

For example you have an a array

$a = array("num"=>"1","university_name"=>"My University","id"=>"2","Year"=>"2013");

For displaying

echo $a['university_name'];

here "university_name" is the index of the array.

George Brighton
  • 5,131
  • 9
  • 27
  • 36