Page 1 of 1

How to print array values

Posted: Thu Nov 14, 2013 12:49 am
by Ankush
Hello all i am new to php kindly tell me ho to ptint only array values. I have the output as-

Array ( [
Which Note is not Shuddha in Raag Durga?

] => stdClass Object ( [questiontext] =>
Which Note is not Shuddha in Raag Durga?

) [
Pa

] => stdClass Object ( [questiontext] =>
Pa

) [
Re

] => stdClass Object ( [questiontext] =>
Re

) [
All Nodes Are Shuddha

] => stdClass Object ( [questiontext] =>
All Nodes Are Shuddha

) [
Dha

] => stdClass Object ( [questiontext] =>
Dha

) )


I want only questionn and its option kindly help

Re: How to print array values

Posted: Thu Nov 14, 2013 2:41 am
by requinix
You do have the questions and answers already. What do you want to do with them?

Re: How to print array values

Posted: Sun Nov 17, 2013 11:16 pm
by Ankush
i want only text values not in array format....i want to get specific values but not in array format or better i say i want to fetch array values

Re: How to print array values

Posted: Sun Nov 17, 2013 11:34 pm
by Ankush
and also hoe to get individual values from this structutre.....
array ( '
All Nodes Are Shuddha

' => stdClass::__set_state(array( 'answer' => '
All Nodes Are Shuddha

', )), )

Re: How to print array values

Posted: Mon Nov 18, 2013 2:25 am
by requinix
Ankush wrote:i want only text values not in array format....i want to get specific values but not in array format or better i say i want to fetch array values
They've already been fetched. Next you do something with the values. Probably involves a foreach loop. If it doesn't then you actually have to be, you know, specific about what you want to do with the data.
Ankush wrote:and also hoe to get individual values from this structutre.....
array ( '
All Nodes Are Shuddha

' => stdClass::__set_state(array( 'answer' => '
All Nodes Are Shuddha

', )), )
That's a string you got from var_export()ing something. Instead of doing that, deal with the actual variable you tried to export.

Re: How to print array values

Posted: Mon Dec 09, 2013 11:28 am
by CoursesWeb
Hi
Tryy traverse the array with foreach(). Something like this for your array.

Code: Select all

foreach($your_array as $key => $val) {
  echo $val->questiontext;
}