I'm trying to get data out of a variable called $items
When I var_dump($items); - the result is like this:
array(13) {
[0]=> object(stdClass)#868 (2) {
["meta_key"]=> string(17) "Email of Attendee"
["meta_value"]=> string(68) "some-email@gmail.com"
}
[2]=> object(stdClass)#804 (2) {
["meta_key"]=> string(28) "Name to be printed on badge:"
["meta_value"]=> string(7) "some name to be printed"
}
...and so on 11 more times
I want to know if it is possible to get the email from $items with code that something like this:
$email = $items
find the object where meta_key
has the value "Email of Attendee"
then return me the corresponding value.
What I ended up doing was running $items
through a foreach loop like so:
foreach($items as $item){
$items[$item->meta_key]=$item->meta_value;
}
Which converts all the "meta_keys" into the values that they were referencing. now:
$email = $items["Email of Attendee"]
echo $email;
result is some-email@gmail.com
Posting this so that a. someone else in a similar jam might use the for each loop that converts things
b. someone with more experience can suggest a way to get the "Email of Attendee directly from the $items, without having to run it through a foreach loop.