When In print_r or var_dump
echo "<pre>";
echo var_dump($groupname);
echo "</pre>";
I got the result
array(2) {
[0]=>
object(stdClass)#330 (1) {
["name"]=>
string(3) "AAA"
}
[1]=>
object(stdClass)#332 (1) {
["name"]=>
string(3) "BBB"
}
}
Now I want to got the result from the array.
AAA | BBB
You might want to start out by looking on how arrays work. Also if you don’t know “what” an array is, look over this Wikipedia entry.
Examples from PHP.NET
Declare an indexes and values
Here is another example with the results
Result of the above:
Your special problem
Now it looks to me that you want to select each name from each record / row in your array / list.
To do this you need to loop / iterate throughout the array and write the current rows name-value.
Example on looping with arrays
Doing this without loops
So let’s say that you know that your array only has two values, well then if you had an array looking like this:
You could write something like this to write them out:
Remember that when you tell your array which “row” to get, you always say “how many steps to go”, meaning that if you want the first value, you take 0 steps, therefore the index is… 0!
Object orientation and arrays
Since you are using an object in your array you might want to check out some information about PHP and Object Oriented Programming.
Side note and a cool example
See this cool example which might give you an idea on what you can do