Nathan Riley
asked on
PHP Pull from Array
I'm trying to:
values->likes->_total
and
values->updateComments->_t otal
From this array.
I've tried this but not working.
values->likes->_total
and
values->updateComments->_t
From this array.
array(2) {
["_total"]=>
int(2)
["values"]=>
array(2) {
[0]=>
array(10) {
["isCommentable"]=>
bool(true)
["isLikable"]=>
bool(true)
["isLiked"]=>
bool(false)
["likes"]=>
array(2) {
["_total"]=>
int(1)
["values"]=>
array(1) {
[0]=>
array(0) {
}
}
}
["numLikes"]=>
int(1)
["timestamp"]=>
int(1437164088854)
["updateComments"]=>
array(2) {
["_total"]=>
int(1)
["values"]=>
array(1) {
[0]=>
array(5) {
["comment"]=>
string(4) "...."
["company"]=>
array(2) {
["id"]=>
int(6408466)
["name"]=>
string(17) "Odem Global, Inc."
}
["id"]=>
int(6027903381492817920)
["sequenceNumber"]=>
int(0)
["timestamp"]=>
int(1437164159147)
}
}
}
["updateContent"]=>
array(2) {
["company"]=>
array(2) {
["id"]=>
int(6408466)
["name"]=>
string(17) "Odem Global, Inc."
}
["companyStatusUpdate"]=>
array(1) {
["share"]=>
array(5) {
["comment"]=>
string(36) "Test LinkedIn test description123123"
["id"]=>
string(20) "s6027903086507409408"
["source"]=>
array(3) {
["application"]=>
array(1) {
["name"]=>
string(17) "Odem Global Login"
}
["serviceProvider"]=>
array(1) {
["name"]=>
string(8) "LINKEDIN"
}
["serviceProviderShareId"]=>
string(20) "s6027903086507409408"
}
["timestamp"]=>
int(1437164088854)
["visibility"]=>
array(1) {
["code"]=>
string(6) "anyone"
}
}
}
}
["updateKey"]=>
string(35) "UPDATE-c6408466-6027903086494838784"
["updateType"]=>
string(4) "CMPY"
}
[1]=>
array(6) {
["isCommentable"]=>
bool(false)
["isLikable"]=>
bool(false)
["timestamp"]=>
int(1436885039866)
["updateContent"]=>
array(2) {
["company"]=>
array(2) {
["id"]=>
int(6408466)
["name"]=>
string(17) "Odem Global, Inc."
}
["companyJobUpdate"]=>
array(2) {
["action"]=>
array(1) {
["code"]=>
string(4) "none"
}
["job"]=>
array(6) {
["company"]=>
array(2) {
["id"]=>
int(6408466)
["name"]=>
string(17) "Odem Global, Inc."
}
["description"]=>
string(1028) "Award winning global marketing agency with groundbreaking technology offering is seeking a Marketing Director to support both client and internal initiatives. Qualified candidates will have:  - Ability to put together a sound marketing recommendation (strategy and plan) from a client brief of category, budget, and goal. - Experience with cross-channel, integrated marketing solutions (Design, Development, Production, and Media) including Traditional "above the line" tactics, Digital, Social, Search, and Influencer Marketing.  - Bachelors Degree in Marketing, Communications, Advertising, or similar from reputable four year College or University. (Advanced degree a plus but not required)  - Minimum of four years experience at a major advertising, marketing communications, media, or public relations firm. - Direct client management experience having served as day-to-day lead. (Managerial experience a plus but not required) Responsibilities will include: - Providing strategic oversight to day-to-day team - Lea"
["id"]=>
int(62367178)
["locationDescription"]=>
string(26) "Greater New York City Area"
["position"]=>
array(1) {
["title"]=>
string(18) "Marketing Director"
}
["siteJobRequest"]=>
array(1) {
["url"]=>
string(53) "https://www.linkedin.com/jobs?viewJob=&jobId=62367178"
}
}
}
}
["updateKey"]=>
string(35) "UPDATE-c6408466-6026732670262796289"
["updateType"]=>
string(4) "CMPY"
}
}
}
I've tried this but not working.
for($i=0; $i<$data['_total']; ++$i){
$id = $data['values'][$i]['likes'];
$name=$data['values'][$i]['updateComments'];
echo $id.' '.$name;
And now that I look at it a little more, I'm thinking that the original data was in a different format. Perhaps it was a JSON string or an XML document? If you can give us the complete text of the original data, we might be able to show you a good way of handling this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://php.net/manual/en/function.var-export.php
If you can give us a var_export() representation, I'm sure we can give you a tested and working example quickly!