Hello, I'm really stumped as to why the piece of code that I have isn't working, and is in fact giving me an error. I have a multidimensional array ($results) that contains the following:
You get the gist of it... Now what I want to do is take the "id_str" column of each array within the array, and assign it to a new array. I have tried a couple of different ways, none of which have worked.
Here are a few of my tries...
I also tried it with the number 7 in the second access of $results since I know that "id_str" is always in the 7th spot, but that didn't work either.
Also, the 3 in the loop is just for testing purposes.
array(50) {
[0]=>
object(stdClass)#9 (18) {
["created_at"]=>
string(31) "Tue, 11 Dec 2012 04:09:29 +0000"
["from_user"]=>
string(9) "jordklotz"
["from_user_id"]=>
int(67114977)
["from_user_id_str"]=>
string(8) "67114977"
["from_user_name"]=>
string(12) "Jordan Klotz"
["geo"]=>
NULL
["id"]=>
float(2.7835077069964E+17)
["id_str"]=>
string(18) "278350770699644928"
["iso_language_code"]=>
string(2) "en"
["metadata"]=>
object(stdClass)#10 (1) {
["result_type"]=>
string(6) "recent"
}
["profile_image_url"]=>
string(90) "http://a0.twimg.com/profile_images/2763602606/cb1c224c304edf6ce23776a6c81e37df_normal.jpeg"
["profile_image_url_https"]=>
string(92) "https://si0.twimg.com/profile_images/2763602606/cb1c224c304edf6ce23776a6c81e37df_normal.jpeg"
["source"]=>
string(89) "<a href="http://twitter.com/download/iphone">Twitter for iPhone</a>"
["text"]=>
string(29) "RT @tMaCkTiMeS: don't test me"
["to_user"]=>
NULL
["to_user_id"]=>
int(0)
["to_user_id_str"]=>
string(1) "0"
["to_user_name"]=>
NULL
}
[1]=>
object(stdClass)#11 (18) {
["created_at"]=>
string(31) "Tue, 11 Dec 2012 04:09:29 +0000"
["from_user"]=>
string(10) "marianaaem"
["from_user_id"]=>
int(177839089)
["from_user_id_str"]=>
string(9) "177839089"
["from_user_name"]=>
string(18) "Mariana Escalante "
["geo"]=>
NULL
["id"]=>
float(2.7835076986079E+17)
["id_str"]=>
string(18) "278350769860788224"
["iso_language_code"]=>
string(2) "en"
["metadata"]=>
object(stdClass)#12 (1) {
["result_type"]=>
string(6) "recent"
}
["profile_image_url"]=>
string(89) "http://a0.twimg.com/profile_images/2675105716/6fc399aa6815b67da1744de4057dd2f6_normal.png"
["profile_image_url_https"]=>
string(91) "https://si0.twimg.com/profile_images/2675105716/6fc399aa6815b67da1744de4057dd2f6_normal.png"
["source"]=>
string(59) "<a href="http://twitter.com/">web</a>"
["text"]=>
string(65) "@Harry_Styles @NiallOfficial BOTH ONLINE AND I HAVE TEST TOMORROW"
["to_user"]=>
string(12) "Harry_Styles"
["to_user_id"]=>
int(181561712)
["to_user_id_str"]=>
string(9) "181561712"
["to_user_name"]=>
string(12) "Harry Styles"
}
You get the gist of it... Now what I want to do is take the "id_str" column of each array within the array, and assign it to a new array. I have tried a couple of different ways, none of which have worked.
Here are a few of my tries...
$tweetIds = array(50);
// loop through $results and store them
for($i=0; $i<3; $i++)
{
$tweetIds[$i] = $results[$i]["id_str"];
}
I also tried it with the number 7 in the second access of $results since I know that "id_str" is always in the 7th spot, but that didn't work either.
Also, the 3 in the loop is just for testing purposes.