How to fetch data from array and insert to database - php

Hello i Have a problem related to array,i am trying to request graph api and saves data in database.here is my array
Array
(
[threadId] => t_mid.1445648572476:316f06a4adc6d7dd57
[sender] => Array
(
[0] => Array
(
[0] => stdClass Object
(
[name] => rajesh Prasad Shah
[email] => 543634645764577#facebook.com
[id] => 543634645764577
)
[1] => stdClass Object
(
[name] => rjtest
[email] => 849929567895403#facebook.com
[id] => 849929567895403
)
)
)
[messages] => Array
(
[messages] => Array
(
[0] => Array
(
[message] => Same to u dear.
[from] => stdClass Object
(
[name] => rajesh Prasad Shah
[email] => 543634645764577#facebook.com
[id] => 543634645764577
)
[created_time] => 2015-12-31T11:31:24+0000
[id] => m_mid.1451561484487:5b3276ddd9d86d1480
[to] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => rjtest
[email] => 849929567895403#facebook.com
[id] => 849929567895403
)
)
)
[tags] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => inbox
)
[1] => stdClass Object
(
[name] => source:chat
)
)
)
)
[1] => Array
(
[message] => Happy New Year to all of you
[from] => stdClass Object
(
[name] => rjtest
[email] => 849929567895403#facebook.com
[id] => 849929567895403
)
[created_time] => 2015-12-31T10:37:47+0000
[id] => m_mid.1451558267514:4c017e5a1f8e997586
[to] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => rajesh Prasad Shah
[email] => 543634645764577#facebook.com
[id] => 543634645764577
)
)
)
[tags] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => inbox
)
[1] => stdClass Object
(
[name] => read
)
[2] => stdClass Object
(
[name] => sent
)
[3] => stdClass Object
(
[name] => source:web
)
)
)
)
[2] => Array
(
[message] => Happy New Year to all of you
[from] => stdClass Object
(
[name] => rjtest
[email] => 849929567895403#facebook.com
[id] => 849929567895403
)
[created_time] => 2015-12-31T09:44:49+0000
[id] => m_mid.1451555089630:1036078c7bcabeed78
[to] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => rajesh Prasad Shah
[email] => 543634645764577#facebook.com
[id] => 543634645764577
)
)
)
[tags] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => inbox
)
[1] => stdClass Object
(
[name] => read
)
[2] => stdClass Object
(
[name] => sent
)
[3] => stdClass Object
(
[name] => source:web
)
)
)
)
[3] => Array
(
[message] => Happy New Year to all of you
[from] => stdClass Object
(
[name] => rjtest
[email] => 849929567895403#facebook.com
[id] => 849929567895403
)
[created_time] => 2015-12-31T09:43:28+0000
[id] => m_mid.1451555008621:62c3365e35ededc773
[to] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => rajesh Prasad Shah
[email] => 543634645764577#facebook.com
[id] => 543634645764577
)
)
)
[tags] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => inbox
)
[1] => stdClass Object
(
[name] => read
)
[2] => stdClass Object
(
[name] => sent
)
[3] => stdClass Object
(
[name] => source:web
)
)
)
)
[4] => Array
(
[message] => Very Good
[from] => stdClass Object
(
[name] => rajesh Prasad Shah
[email] => 543634645764577#facebook.com
[id] => 543634645764577
)
[created_time] => 2015-09-01T09:13:34+0000
[id] => m_mid.1445648574720:c2746f8b55fff17369
[to] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => rjtest
[email] => 849929567895403#facebook.com
[id] => 849929567895403
)
)
)
[tags] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => inbox
)
[1] => stdClass Object
(
[name] => read
)
[2] => stdClass Object
(
[name] => source:chat
)
)
)
)
[5] => Array
(
[message] => Good
[from] => stdClass Object
(
[name] => rajesh Prasad Shah
[email] => 543634645764577#facebook.com
[id] => 543634645764577
)
[created_time] => 2015-09-01T09:13:32+0000
[id] => m_mid.1445648572476:316f06a4adc6d7dd57
[to] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => rjtest
[email] => 849929567895403#facebook.com
[id] => 849929567895403
)
)
)
[tags] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => inbox
)
[1] => stdClass Object
(
[name] => read
)
[2] => stdClass Object
(
[name] => source:chat
)
)
)
)
)
)
)
This is my php code from that i fetch data
foreach($data as $evaluatemessage){
//echo "<pre>";print_r($evaluatemessage); die;
$inbox=array();
$inbox['thread_id']=$evaluatemessage['threadId'];
foreach($evaluatemessage['messages'] as $messagedet){
//print_r($messagedet[0]['id']); die;
$inbox['smg_id']=$messagedet[$j]['id'];
$inbox['body']=$messagedet[$j]['message'];
$inbox['time']=$messagedet[$j]['created_time'];
//$inbox['msg_type']=$data;
//$inbox['user_id']=$data;
$inbox['From_name']=$messagedet[$j]['from']->name;
$inbox['To_name']=$messagedet[$j]['to']->data[0]->name;
$inbox['From_id']=$messagedet[$j]['from']->id;
$inbox['To_id']=$messagedet[$j]['to']->data[0]->id;
$inbox['tags']=$messagedet[$j]['tags']->data[1]->name;
//$inbox['Page_id']=$data;
//echo "<pre>";print_r($inbox); die;
$inbox['Page_id']='12345';
$this->facebook_inboxes->save($inbox);
$j++;
}
$i++;
}
when i hit with this code only a single threadid and single message contents are saved.but rest are not,i want every thread id with there all messages id and message body are saved row by row but unable to do that can anyone help me how i do that.

Write this code before Save function
$this->facebook_inboxes->create();
This is enbuild function of cake to store multiple row.

There is another messages array inside the messages array. So according to your array structure, your second loop will be like this :
foreach($evaluatemessage['messages']['messages'] as $messagedet){
//print_r($messagedet[0]['id']); die;
$inbox['smg_id']=$messagedet[$j]['id'];
$inbox['body']=$messagedet[$j]['message'];
$inbox['time']=$messagedet[$j]['created_time'];
.
.
.
}
and you are using only:
foreach($evaluatemessage['messages'] as $messagedet){}
here is the full code :
foreach($data as $evaluatemessage){
//echo "<pre>";print_r($evaluatemessage); die;
$inbox=array();
$inbox['thread_id']=$evaluatemessage['threadId'];
foreach($evaluatemessage['messages']['messages'] as $messagedet){
//print_r($messagedet[0]['id']); die;
$inbox['smg_id']=$messagedet[$j]['id'];
$inbox['body']=$messagedet[$j]['message'];
$inbox['time']=$messagedet[$j]['created_time'];
//$inbox['msg_type']=$data;
//$inbox['user_id']=$data;
$inbox['From_name']=$messagedet[$j]['from']->name;
$inbox['To_name']=$messagedet[$j]['to']->data[0]->name;
$inbox['From_id']=$messagedet[$j]['from']->id;
$inbox['To_id']=$messagedet[$j]['to']->data[0]->id;
$inbox['tags']=$messagedet[$j]['tags']->data[1]->name;
//$inbox['Page_id']=$data;
//echo "<pre>";print_r($inbox); die;
$inbox['Page_id']='12345';
$this->facebook_inboxes->save($inbox);
$j++;
}
$i++;
}

Related

PHP parse soapClient response transfer to a table

I'm just on the hose and dont get on.
I am not a professional programmer but have so far with much reading and over numerous attempts everything so far created what I have undertaken, only with this I have probably found my masterpiece.
I have a response of a SOAP query and would like to display the values in a table for each powerUnitidentifier. What is the best way to do this?
(
[RawData] => stdClass Object
(
[from] => 2022-05-10T01:00:00+02:00
[to] => 2022-05-10T01:20:00+02:00
[dataRecords] => stdClass Object
(
[record] => Array
(
[0] => stdClass Object
(
[powerUnitIdentifier] => abc123
[time] => 2022-05-10T01:00:00+02:00
[fields] => stdClass Object
(
[field] => Array
(
[0] => stdClass Object
(
[identifier] => 100
[value] => 0
)
[1] => stdClass Object
(
[identifier] => 101
[value] => 3.27
)
[2] => stdClass Object
(
[identifier] => 102
[value] => 70.00
)
)
)
)
[1] => stdClass Object
(
[powerUnitIdentifier] => zyx321
[time] => 2022-05-10T01:00:00+02:00
[fields] => stdClass Object
(
[field] => Array
(
[0] => stdClass Object
(
[identifier] => 100
[value] => 0
)
[1] => stdClass Object
(
[identifier] => 101
[value] => 3.19
)
[2] => stdClass Object
(
[identifier] => 102
[value] => 70.00
)
)
)
)
[2] => stdClass Object
(
[powerUnitIdentifier] => abc123
[time] => 2022-05-10T01:10:00+02:00
[fields] => stdClass Object
(
[field] => Array
(
[0] => stdClass Object
(
[identifier] => 100
[value] => 0
)
[1] => stdClass Object
(
[identifier] => 101
[value] => 3.15
)
[2] => stdClass Object
(
[identifier] => 102
[value] => 70.00
)
)
)
)
[3] => stdClass Object
(
[powerUnitIdentifier] => zyx321
[time] => 2022-05-10T01:10:00+02:00
[fields] => stdClass Object
(
[field] => Array
(
[0] => stdClass Object
(
[identifier] => 100
[value] => 0
)
[1] => stdClass Object
(
[identifier] => 101
[value] => 3.09
)
[2] => stdClass Object
(
[identifier] => 102
[value] => 70.00
)
)
)
)
)
)
)
)```
You loop over the section of the data, starting the foreach loop at the right level of your data structure
foreach($theName->RawData->DataRecords->record as $obj) {
echo $obj->powerUnitIdentifier;
}
Or if you ment to process the sub array of that
foreach($theName->RawData->DataRecords->record as $obj) {
echo $obj->powerUnitIdentifier . '<br>';
foreach( $obj->fields as $field) {
echo $field->identifier . ',' . $field->value . '<br>';
}
}

Php how to print array response in print_r

I got a response like this now i want to print
[products] how to print
i try this print_r($response['products']);
My Response
stdClass Object
(
[users] => Array
(
[0] => stdClass Object
(
[username] => admin
[firstName] => admin
[lastName] => admin
[products] => Array
(
[0] => stdClass Object
(
[name] => 1
[url] => mytest.html
)
[1] => stdClass Object
(
[name] => 2
[url] => mytest.html
)
[2] => stdClass Object
(
[name] => 3
[url] => mytest.html
)
[3] => stdClass Object
(
[name] => 4
[url] => mytest.html
)
[4] => stdClass Object
(
[name] => 5
[url] => mytest.html
)
[5] => stdClass Object
(
[name] => 6
[url] => mytest.html
)
[6] => stdClass Object
(
[name] => 7
[url] => mytest.html
)
)
)
)
[error] =>
[errorMessage] =>
)
Try This one
print_r($response->users['0']->products);

Instagram API Standard Object

I am attempting to parse the Instagram API standard object that looks like this:
stdClass Object
(
[pagination] => stdClass Object
(
[next_url] => https://api.instagram.com/v1/users /283549787/media/recent?access_token=3036118427.1677ed0.fceea7d5e10440b691a670ddb6a97783&max_id=1059902719332635377_283549787
[next_max_id] => 1059902719332635377_283549787
)
[meta] => stdClass Object
(
[code] => 200
)
[data] => Array
(
[0] => stdClass Object
(
[attribution] =>
[tags] => Array
(
[0] => vbb
[1] => 100k
[2] => ig
)
[type] => image
[location] =>
[comments] => stdClass Object
(
[count] => 22
[data] => Array
(
[0] => stdClass Object
(
[created_time] => 1461241283
[text] => weeeelll 💥
[from] => stdClass Object
(
[username] => thewolfcult
[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/12519175_228551560821189_1928102794_a.jpg
[id] => 2685463016
[full_name] => Wolf Cult
)
[id] => 17846791729091814
)
[1] => stdClass Object
(
[created_time] => 1461241621
[text] => this pic is LOL 😂😂😂
[from] => stdClass Object
(
[username] => class_y_man
[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/13129374_610084285824464_241975035_a.jpg
[id] => 189866780
[full_name] => Z.k
)
[id] => 17846791822091814
)
[2] => stdClass Object
(
[created_time] => 1461241649
[text] => Love it ðŸ˜
[from] => stdClass Object
(
[username] => kosmonelle
[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/13113731_1661552477439373_875045798_a.jpg
[id] => 2371520392
[full_name] =>
)
[id] => 17846791834091814
)
[3] => stdClass Object
(
[created_time] => 1461254879
[text] => ðŸ†ðŸ‘
[from] => stdClass Object
(
[username] => modelsandphotographers1
[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/11336128_1774042986155389_99539322_a.jpg
[id] => 1418124928
[full_name] => Best Models & Photographers
)
[id] => 17846795935091814
)
)
)
[filter] => Normal
[created_time] => 1461230731
[link] => https://www.instagram.com/p/BEdQrSDytME/
[likes] => stdClass Object
(
[count] => 16672
[data] => Array
(
[0] => stdClass Object
(
[username] => jassi_bains_official
[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/12327958_458252344360785_973161765_a.jpg
[id] => 2302067650
[full_name] => Jassi bains
)
[1] => stdClass Object
(
[username] => ukay.tlb527
[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/11906329_960233084022564_1448528159_a.jpg
[id] => 3101669439
[full_name] => Melvin Rosetta
)
[2] => stdClass Object
(
[username] => hahmedhossam121414411
[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/11906329_960233084022564_1448528159_a.jpg
[id] => 3150267725
[full_name] => Bobby Ivan
)
[3] => stdClass Object
(
[username] => somi__0
[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/13102392_989473131142748_1189753865_a.jpg
[id] => 2190016506
[full_name] => Somi 👸ðŸ¼ðŸ’•
)
)
)
[images] => stdClass Object
(
[low_resolution] => stdClass Object
(
[url] => https://scontent.cdninstagram.com/t51.2885-15/s320x320/e35/12918470_1000175006702614_1067887222_n.jpg?ig_cache_key=MTIzMzIxNTIxNjA0MjAzODAyMA%3D%3D.2.l
[width] => 320
[height] => 320
)
[thumbnail] => stdClass Object
(
[url] => https://scontent.cdninstagram.com/t51.2885-15/s150x150/e35/c190.0.644.644/12918387_1540009256304246_510188281_n.jpg?ig_cache_key=MTIzMzIxNTIxNjA0MjAzODAyMA%3D%3D.2.c
[width] => 150
[height] => 150
)
[standard_resolution] => stdClass Object
(
[url] => https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/12918470_1000175006702614_1067887222_n.jpg?ig_cache_key=MTIzMzIxNTIxNjA0MjAzODAyMA%3D%3D.2.l
[width] => 640
[height] => 640
)
)
[users_in_photo] => Array
(
)
[caption] => stdClass Object
(
[created_time] => 1461230731
[text] => really , thank you 🆠#ig #100k #vbb
[from] => stdClass Object
(
[username] => mattiacanfa
[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/13113786_488414981352515_1701597009_a.jpg
[id] => 283549787
[full_name] => Mattia Canfarotta
)
[id] => 17846789149091814
)
[user_has_liked] =>
[id] => 1233215216042038020_283549787
[user] => stdClass Object
(
[username] => mattiacanfa
[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/13113786_488414981352515_1701597009_a.jpg
[id] => 283549787
[full_name] => Mattia Canfarotta
)
)
)
I am trying to get standard_resolution url like this with $json_result being the object:
foreach ($json_result->data->images->standard_resolution->url as $images){
print_r($images);
}
For some reason nothing is being returned.
I was able to resolve because data is an array it needs to be this:
foreach ($json_result->data as $data){
foreach ($data->images->standard_resolution as $link){
echo "<img src='$link'></img>";
}
}

How to loop through a LinkedIn API response?

I am retrieving connections via LinkedIn's API.
This is a sample of the response. All I want to do is loop through this using PHP, accessing first and last names. Should be simple, but I am stumped. Thanks.
stdClass Object ( [_total] => 420 [values] => Array ( [0] => stdClass
Object ( [apiStandardProfileRequest] => stdClass Object ( [headers] =>
stdClass Object ( [_total] => 1 [values] => Array ( [0] => stdClass
Object ( [name] => x-li-auth-token [value] => name:AnUY ) ) ) [url] =>
http://api.linkedin.com/v1/people/7yw8k_sjqf ) [firstName] => John
[headline] => Finance Manager at ABC. [id] => 7yw8k_sjqf [industry] =>
Insurance [lastName] => Doe [location] => stdClass Object ( [country]
=> stdClass Object ( [code] => us ) [name] => Greater Atlanta Area ) [pictureUrl] =>
http://m.c.lnkd.licdn.com/mpr/mprx/0_73E_PMM3nzAIZLG03bHpPRo3qvCwZL_0DhYpPRogIxiFs7jUYPVRGNRGC1mGegyyqdihoC
[siteStandardProfileRequest] => stdClass Object ( [url] =>
http://www.linkedin.com/profile/view?id=2633833&authType=name&authToken=AnUY&trk=api*a189561*s197687*
) ) [1] => stdClass Object ( [apiStandardProfileRequest] => stdClass
Object ( [headers] => stdClass Object ( [_total] => 1 [values] =>
Array ( [0] => stdClass Object ( [name] => x-li-auth-token [value] =>
name:tpAo ) ) ) [url] => http://api.linkedin.com/v1/people/FW8obZbI8R
) [firstName] => Jeremy [headline] => Owner, BCD [id] => FW8obZbI8R
[industry] => Computer Software [lastName] => Doe [location] =>
stdClass Object ( [country] => stdClass Object ( [code] => us ) [name]
=> Greater Chicago Area ) [pictureUrl] => http://m.c.lnkd.licdn.com/mpr/mprx/0_Lw2NlImcd1e6LmQpL2mIleOMIcf9LeFpbu4IlexHq-R6V2ryWSpZ0HI6LM7rXeaEYf3Gt69H
[siteStandardProfileRequest] => stdClass Object ( [url] =>
http://www.linkedin.com/profile/view?id=6700159&authType=name&authToken=tpAo&trk=api*a189561*s197687*
) ) [2] => stdClass Object ( [apiStandardProfileRequest] => stdClass
Object ( [headers] => stdClass Object ( [_total] => 1 [values] =>
Array ( [0] => stdClass Object ( [name] => x-li-auth-token [value] =>
name:eETp ) ) ) [url] => http://api.linkedin.com/v1/people/a7-dvlvc7K
) [firstName] => Jane [headline] => Sr. Consultant System Integration
at AT&T [id] => a7-dvlvc7K [industry] => Telecommunications [lastName]
=> Doe [location] => stdClass Object ( [country] => stdClass Object ( [code] => us ) [name] => Greater New York City Area ) [pictureUrl] =>
http://m.c.lnkd.licdn.com/mpr/mprx/0_459zxGU8TBpTZjvisicExTgSSvZCsYXisCGExTR-t1ut5V1_N_6JA37p_Z4gJQqIK653RvmW
[siteStandardProfileRequest] => stdClass Object ( [url] =>
http://www.linkedin.com/profile/view?id=119413921&authType=name&authToken=eETp&trk=api*a189561*s197687*
) ) [3] => stdClass Object ( [apiStandardProfileRequest] => stdClass
Object ( [headers] => stdClass Object ( [_total] => 1 [values] =>
Array ( [0] => stdClass Object ( [name] => x-li-auth-token [value] =>
name:HjUG ) ) ) [url] => http://api.linkedin.com/v1/people/aie8Zpk9Gm
) [firstName] => John [headline] => Financial Information/Market Data
Professional [id] => aie8Zpk9Gm [industry] => Financial Services
[lastName] => Smith [location] => stdClass Object ( [country] =>
stdClass Object ( [code] => gb ) [name] => Glasgow, United Kingdom )
[pictureUrl] =>
http://m.c.lnkd.licdn.com/mpr/mprx/0_N0TLAL3BTlHZCVAbTNTAD03RCjngvsAbCIY-JfOxvg4JldxF9L7MShCp_Avp_ROhKS8LNY
[siteStandardProfileRequest] => stdClass Object ( [url] =>
http://www.linkedin.com/profile/view?id=1562499&authType=name&authToken=HjUG&trk=api*a189561*s197687*
) ) [4] => stdClass Object ( [apiStandardProfileRequest] => stdClass
Object ( [headers] => stdClass Object ( [_total] => 1 [values] =>
Array ( [0] => stdClass Object ( [name] => x-li-auth-token [value] =>
name:aZIS ) ) ) [url] => http://api.linkedin.com/v1/people/XTGgSuagWI
) [firstName] => Bob [headline] => CEO, Nycomed US at NMO [id] =>
XTGgSuagWI [industry] => Pharmaceuticals [lastName] => brown
[location] => stdClass Object ( [country] => stdClass Object ( [code]
=> us ) [name] => Greater New York City Area ) [pictureUrl] => http://m.c.lnkd.licdn.com/mpr/mprx/0_UciCehxmKngbM15je_qytdVG-zSbJrcje_92S7a-DlsFcA1m6iCGyXsjl-uwsq3ybXXbrd1L
[siteStandardProfileRequest] => stdClass Object ( [url] =>
What you have as the response is an stdclass which will have all of its properties public.
This is how you iterate it:
$response = $this->getResponseFromLinkedIn();
foreach ($response->values as $value) {
$firstName = $value->firstName;
$lastName = $value->lastName;
// do something with the extracted values!
}

Having problems with recursive array objects (stdClass Object)

I'm hoping someone can help me with my syntax. I think that's the issue. I'm trying to have the loop go through display the chosen object, but it's not working. Here is my code.
stdClass Object
(
[result_count] => 2
[total_count] => 2
[next_offset] => 2
[entry_list] => Array
(
[0] => stdClass Object
(
[id] => da2b0ab5-873b-d9a8-0fcd-5180871e57eb
[module_name] => Project
[name_value_list] => stdClass Object
(
[description] => stdClass Object
(
[name] => description
[value] => soccer is fun!!!
)
[priority] => stdClass Object
(
[name] => priority
[value] => Primary
)
[total_years_played_c] => stdClass Object
(
[name] => total_years_played_c
[value] => 5
)
[sport_c] => stdClass Object
(
[name] => sport_c
[value] => Soccer
)
[high_school_exp_c] => stdClass Object
(
[name] => high_school_exp_c
[value] => 2
)
[varsity_exp_c] => stdClass Object
(
[name] => varsity_exp_c
[value] => default
)
[hand_right_c] => stdClass Object
(
[name] => hand_right_c
[value] => 0
)
[hand_left_c] => stdClass Object
(
[name] => hand_left_c
[value] => 1
)
[foot_right_c] => stdClass Object
(
[name] => foot_right_c
[value] => 1
)
[foot_left_c] => stdClass Object
(
[name] => foot_left_c
[value] => 0
)
[specialskills_c] => stdClass Object
(
[name] => specialskills_c
[value] =>
)
[varsity_starter_c] => stdClass Object
(
[name] => varsity_starter_c
[value] => 0
)
)
)
[1] => stdClass Object
(
[id] => 2e805552-c887-2b2e-a9e5-518087f3f87a
[module_name] => Project
[name_value_list] => stdClass Object
(
[description] => stdClass Object
(
[name] => description
[value] => I bleed for hockey... I will teach your kid to put them on the boards and take no prisoners!
)
[priority] => stdClass Object
(
[name] => priority
[value] => Secondary
)
[total_years_played_c] => stdClass Object
(
[name] => total_years_played_c
[value] => 7
)
[sport_c] => stdClass Object
(
[name] => sport_c
[value] => Hockey
)
[high_school_exp_c] => stdClass Object
(
[name] => high_school_exp_c
[value] => 3
)
[varsity_exp_c] => stdClass Object
(
[name] => varsity_exp_c
[value] => 2
)
[hand_right_c] => stdClass Object
(
[name] => hand_right_c
[value] => 0
)
[hand_left_c] => stdClass Object
(
[name] => hand_left_c
[value] => 1
)
[foot_right_c] => stdClass Object
(
[name] => foot_right_c
[value] => 1
)
[foot_left_c] => stdClass Object
(
[name] => foot_left_c
[value] => 0
)
[specialskills_c] => stdClass Object
(
[name] => specialskills_c
[value] =>
)
[varsity_starter_c] => stdClass Object
(
[name] => varsity_starter_c
[value] => 0
)
)
)
)
[relationship_list] => Array
(
)
)
Here is the PHP that I am using. For now, I'm just wanting to echo the name of sport_c (one should be Hockey, the other should be Soccer)
<?
foreach($response->entry_list as $sports) {
if(!empty($sports->name_value_list->sport_c)) {
$sport_list = $sports->name_value_list->sport_c;
$sport_name = $sport_list->value;
}
}
echo $sport_name;
?>
Put the echo statement within the foreach loop:
foreach($response->entry_list as $sports) {
if(!empty($sports->name_value_list->sport_c)) {
$sport_list = $sports->name_value_list->sport_c;
$sport_name = $sport_list->value;
}
echo $sport_name;
}

Categories