Search the Community
Showing results for tags 'multidimensional arrays'.
-
I have a multidimensional array like so. Array ( [0] => Array ( [0] => Yolo County Sheriff's Home 2008faroo [1] => http://www.yolosheriffs.com/ [2] => 86 ) [1] => Array ( [0] => Fremont, Yolo County, California - Wikipedia, the free encyclopediafaroo [1] => http://en.wikipedia.org/wiki/Fremont,_Yo… [2] => 11 ) [2] => Array ( [0] => The Lonely Island - YOLO (feat. Adam Levine & Kendrick Lamar) - YouTubefaroo [1] => http://www.youtube.com/watch?feature=pla… [2] => 45 ) What i need to do is find duplicate urls in this array, merge them together and combine the score found at [2]. I have scoured the php manual but I can't seem to find a way to merge the duplicate urls and then add the scores to the remaining url. Would it make it any easier to have it in the format Array ( [0] => Array ( [0] => Yolo County Sheriff's Home 2008faroo, array([0] => http://www.yolosheriffs.com/ ,[1] => 0) ) ?? All suggestions appreciated.I have looked at the manual but i don't have the knowledge at this stage to use the array functions in conjunction with foreach loops to achieve what i need.I
- 2 replies
-
- php
- multidimensional arrays
-
(and 3 more)
Tagged with:
-
Hello... I simply am running a query with the Twitter Search API that searches for a specific term and then returns the Tweets it finds. This is a sample of what the array of Tweets returned looks like: array(50) { [0]=> object(stdClass)#9 (18) { ["created_at"]=> string(31) "Tue, 11 Dec 2012 04:30:08 +0000" ["from_user"]=> string(7) "Cvpcake" ["from_user_id"]=> int(44610318) ["from_user_id_str"]=> string( "44610318" ["from_user_name"]=> string(6) "KILLER" ["geo"]=> NULL ["id"]=> float(2.7835596410783E+17) ["id_str"]=> string(18) "278355964107829248" ["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/2945542955/d437253418ea0ae75efb5ae6bf5cec1e_normal.jpeg" ["profile_image_url_https"]=> string(92) "https://si0.twimg.com/profile_images/2945542955/d437253418ea0ae75efb5ae6bf5cec1e_normal.jpeg" ["source"]=> string(89) "<a href="http://twitter.com/download/iphone">Twitter for iPhone</a>" ["text"]=> string(57) "RT @DJNickatNIte_: 9 weeks test ain't got shit on #FINALS" ["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:30:07 +0000" ["from_user"]=> string( "BaboTina" ["from_user_id"]=> int(224918169) ["from_user_id_str"]=> string(9) "224918169" ["from_user_name"]=> string(4) "Tina" ["geo"]=> NULL ["id"]=> float(2.783559623588E+17) ["id_str"]=> string(18) "278355962358796288" ["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/2936213945/390fe03b68949baa1bb1af2f2d6fe76e_normal.png" ["profile_image_url_https"]=> string(91) "https://si0.twimg.com/profile_images/2936213945/390fe03b68949baa1bb1af2f2d6fe76e_normal.png" ["source"]=> string(91) "<a href="http://twitter.com/download/android">Twitter for Android</a>" ["text"]=> string(130) "RT @autocorrects: Multiple choice (test): A, B, C, or D? “Well I haven’t had a B for like 4 questions so I’ll choose that”" ["to_user"]=> NULL ["to_user_id"]=> int(0) ["to_user_id_str"]=> string(1) "0" ["to_user_name"]=> NULL } [2]=> object(stdClass)#13 (18) { ["created_at"]=> string(31) "Tue, 11 Dec 2012 04:30:07 +0000" ["from_user"]=> string(13) "SyifaGBastian" ["from_user_id"]=> int(332078990) ["from_user_id_str"]=> string(9) "332078990" ["from_user_name"]=> string(12) "ViscaELBarca" ["geo"]=> NULL ["id"]=> float(2.7835596214069E+17) ["id_str"]=> string(18) "278355962140688385" ["iso_language_code"]=> string(3) "und" ["metadata"]=> object(stdClass)#14 (1) { ["result_type"]=> string(6) "recent" } ["profile_image_url"]=> string(90) "http://a0.twimg.com/profile_images/2921649342/1a38717324614fad5993dc5e4383a925_normal.jpeg" ["profile_image_url_https"]=> string(92) "https://si0.twimg.com/profile_images/2921649342/1a38717324614fad5993dc5e4383a925_normal.jpeg" ["source"]=> string(59) "<a href="http://twitter.com/">web</a>" ["text"]=> string(4) "test" ["to_user"]=> NULL ["to_user_id"]=> int(0) ["to_user_id_str"]=> string(1) "0" ["to_user_name"]=> NULL } Now what I want to do is store the "id_str" field of each Tweet into an array. I'm trying to do this and I thought it would be simple, but I must be doing something wrong. Here is what I have, which results in an error. $tweetIds; // loop through $results and favorite them for($i=0; $i<3; $i++) { $tweetIds[$i] => $results[$i]['id_str']; } I've tried a couple of other things, including... $tweetIds; // loop through $results and favorite them for($i=0; $i<3; $i++) { $tweetIds[$i] => $results[$i]["id_str"]; } and... $tweetIds; // loop through $results and favorite them for($i=0; $i<3; $i++) { $tweetIds[$i] => $results[$i][7]; } But each way has resulted in an error. I can't figure out why. I'm sure it's something simple I'm not doing correctly... thanks for any help
-
Hello Everyone, I am working on a CMS site and I'm stuck very badly with arrays. I don't have much experience with arrays. In fact, this is probably the first time I have used them this heavily. Here is my situation: I have a for each loop with $i++; which takes values from sessions and puts them into arrays: $bundle_pickup[$i]['bundle_ID']=$bundle_ID; $bundle_pickup[$i]['pickup_date']=$_SESSION['bundle'][$bundle_ID]['pickup_date']; $bundle_pickup[$i]['pickup_time']=$_SESSION['bundle'][$bundle_ID]['pickup_time']; $bundle_pickup prints the following total results: Array ( [1] => Array ( [bundle_ID] => 3 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) [2] => Array ( [bundle_ID] => 4 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) [3] => Array ( [bundle_ID] => 5 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) [4] => Array ( [bundle_ID] => 6 [pickup_date] => 2012-11-08 [pickup_time] => 9 AM to 12 PM ) ) Everything so far is good. Here is what I need to do: I need to loop through $bundle_pickup array and find out which arrays are different. I need to get $bundle_pickup['bundle_ID'] of all the unique arrays The idea is, if the customer picks same pickup date and time for all bundles, he only pays one pickup charge. If he chooses multiple pickup dates or times, he will need to pay multiple charges. If two bundles have same pickup dates/times and other two have same ( but different than first two ), the customer will pay two pick up charges. Since this is a CMS site, I will not know the bundle_ID, pickup dates, pickup times and order of the bundles. If anyone can suggest how I can get $bundle_pickup['bundle_ID'] of all the unique arrays, that would be greatly appreciated. Once I have the IDs, I can use them to fetch other data from the database. Thanks in advance. Jatt Surma
- 2 replies
-
- php arrays
- multidimensional arrays
- (and 3 more)