How to print array values

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
Ankush
Forum Newbie
Posts: 10
Joined: Thu Sep 05, 2013 12:22 am

How to print array values

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How to print array values

Post by requinix »

You do have the questions and answers already. What do you want to do with them?
Ankush
Forum Newbie
Posts: 10
Joined: Thu Sep 05, 2013 12:22 am

Re: How to print array values

Post 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
Ankush
Forum Newbie
Posts: 10
Joined: Thu Sep 05, 2013 12:22 am

Re: How to print array values

Post 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

', )), )
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How to print array values

Post 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.
CoursesWeb
Forum Newbie
Posts: 18
Joined: Mon Dec 09, 2013 10:52 am

Re: How to print array values

Post 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;
} 
Post Reply