Parse XML array into php variables - php
I have an XML feed that is automatically generated on one site and I'm trying to copy it over to another and import the data into a mysql db, but, I'm having difficulty as I'm not familiar with arrays broken down into multiple elements.
Does it get processed the same way a standard array would or does each have to be processed separately? Outputted XML example is included below;
[str] => Array
(
[0] => 0
[1] => USD
[2] => USPS
[3] => 4228547
[4] => 486948677
[5] => 7
[6] => IndyGen3
[7] => 1
[8] => 8 units|8
[9] => N/A
[10] => 1
[11] => Unlimited Refill
[12] => Unlimited Refill
[13] => www
[14] => 1297081
[15] => unitACTIVE4228547
[16] => 2
[17] => 0
[18] => unit-486948677
[19] => unit
[20] => ACTIVE
[21] => unit
[22] => 1
[23] => 1
[24] => 47d 23h 24m
[25] => 2013-02-15T19:35:15.153Z
)
[float] => Array
(
[0] => 94.88
[1] => 94.88
)
[date] => Array
(
[0] => 2013-02-15T19:35:15.438Z
[1] => 2013-02-15T19:33:14Z
[2] => 2013-02-15T19:35:02Z
[3] => 2013-04-04T19:00:00Z
)
[arr] => Array
(
[0] => SimpleXMLElement Object
(
[#attributes] => Array
(
[name] => fm_ship_rules
)
[str] => Array
(
[0] => 6,3,25.0,,2013-04-02T19:00:00Z
[1] => 6,7,11.95,,2013-03-22T19:00:00Z
[2] => 6,15,19.95,,2013-04-02T19:00:00Z
[3] => 6,16,19.95,,2013-04-02T19:00:00Z
)
)
[1] => SimpleXMLElement Object
(
[#attributes] => Array
(
[name] => fm_dm_rules_desc
)
[str] => Array
(
[0] => USPS,USPS Priority, 25.0,,2013-04-02T19:00:00Z
[1] => USPS,USPS Two Day,11.95,,2013-03-22T19:00:00Z
[2] => USPS,USPS International Priority Puerto Rico,19.95,,2013-04-02T19:00:00Z
[3] => USPS,USPS International Priority Canada,19.95,,2013-04-02T19:00:00Z
)
)
)
[int] => Array
(
[0] => 8
[1] => 8
[2] => 1
)
)
To access the information in multidimensional array like the one you have above you would use the following notation. Let's say your main array is called $arr.
$sql = "INSERT INTO `mytable`
(
`currency`,
`postal_service`,
`date`,
`amount_1`,
`amount_2`
) VALUES (
'".$arr[str][1]."',
'".$arr[str][2]."',
'".$arr[date][0]."',
'".$arr[float][0]."',
'".$arr[float][1]."'
)";
This is the equivalent of:
$sql = "INSERT INTO `mytable`
(
`currency`,
`postal_service`,
`date`,
`amount_1`,
`amount_2`
) VALUES (
'USD',
'USPS',
'2013-02-15T19:35:15.438Z',
'94.88',
'94.88'
)";
Related
How do I use array_map recursively in PHP?
I am attempting to convert an associative array to a 2D array to allow me to export it to Google Sheets. I've figured out a simplistic solution that works as follows: $headers = $data["resultSets"][0]["headers"]; $rowSet0 = $data["resultSets"][0]["rowSet"][0]; $rowSet1 = $data["resultSets"][0]["rowSet"][1]; $hackresults = array_map(null, $headers, $rowSet0, $rowSet1); This produces the following: ( [0] => Array ( [0] => SEASON_ID [1] => 22017 [2] => 22017 ) [1] => Array ( [0] => Player_ID [1] => 203954 [2] => 203954 ) [2] => Array ( [0] => Game_ID [1] => 0021701118 [2] => 0021701105 ) [3] => Array ( [0] => GAME_DATE [1] => MAR 28, 2018 [2] => MAR 26, 2018 ) [4] => Array ( [0] => MATCHUP [1] => PHI vs. NYK [2] => PHI vs. DEN ) [5] => Array ( [0] => WL [1] => W [2] => W ) [6] => Array ( [0] => MIN [1] => 9 [2] => 27 ) [7] => Array ( [0] => FGM [1] => 2 [2] => 6 ) [8] => Array ( [0] => FGA [1] => 6 [2] => 12 ) [9] => Array ( [0] => FG_PCT [1] => 0.333 [2] => 0.5 ) [10] => Array ( [0] => FG3M [1] => 0 [2] => 0 ) [11] => Array ( [0] => FG3A [1] => 1 [2] => 1 ) [12] => Array ( [0] => FG3_PCT [1] => 0 [2] => 0 ) [13] => Array ( [0] => FTM [1] => 1 [2] => 8 ) [14] => Array ( [0] => FTA [1] => 2 [2] => 10 ) [15] => Array ( [0] => FT_PCT [1] => 0.5 [2] => 0.8 ) [16] => Array ( [0] => OREB [1] => 2 [2] => 1 ) [17] => Array ( [0] => DREB [1] => 1 [2] => 12 ) [18] => Array ( [0] => REB [1] => 3 [2] => 13 ) [19] => Array ( [0] => AST [1] => 0 [2] => 2 ) [20] => Array ( [0] => STL [1] => 0 [2] => 1 ) [21] => Array ( [0] => BLK [1] => 0 [2] => 2 ) [22] => Array ( [0] => TOV [1] => 1 [2] => 4 ) [23] => Array ( [0] => PF [1] => 1 [2] => 5 ) [24] => Array ( [0] => PTS [1] => 5 [2] => 20 ) [25] => Array ( [0] => PLUS_MINUS [1] => 7 [2] => 20 ) [26] => Array ( [0] => VIDEO_AVAILABLE [1] => 1 [2] => 1 ) ) This is the output I'm looking for, but there are 27 "rowSet"s, and it seems there must be a recursive way of performing this task. I've looked at a number of custom array_map_recursive style functions but haven't had any success. Apologies and thanks in advance, I am a terrible novice coder!
You can use argument unpacking. With the ... operator, you can use all the elements under $data["resultSets"][0]["rowSet"] as additional arguments to array_map. $headers = $data["resultSets"][0]["headers"]; $rowSets = $data["resultSets"][0]["rowSet"]; $results = array_map(null, $headers, ...$rowSets); (This isn't recursion, but I think it does what you're trying to do.)
Manipulate a Multi-Multi-Dimensional PHP Array into a nice Multi-Dimensional Array
I know this is considered a somewhat basic PHP Array question but i'm running on 35 hours no sleep and I really just need to finish this up as quickly as posibble so I can get to sleep...sorry just being honest! In PHP I have this variable $design_values If I print_r($design_values); this ARRAY it spits out what is show below. It is "Desing" database records. In this case there is 2 Design records which make up the first 2 Array keyys the 0 and 1 In the application there can be any number of Designs from 0 up to any number. Now under the 2 Design Records are 24 more Array keys for each of the 2 Design Arrays. These 24 Array keys are numbered 0 to 23. Now under each of the 24 Array keys, is 2 keys. One named name and the other named value. I need to take the Array $design_values and create a new Array of that array. The new Array should be formatted much better amd easy to work with. So the name and value keys should make up a key => value. The New array should look more like this.... The reason the current Array is a complete nightmare is because that is the Format I get it in from an existing library which returns this Data from an API call. If someone can help me to manipulate this Array into the desired Array I will be grateful! I have been messing with it for 2 hours with no luck. Desired New Array Format : Array ( [0] => Array ( ['assigned_user_name'] => 'Jason Administrator', ['modified_by_name'] => 'Jason Administrator', ['created_by_name'] => 'Jason Administrator', ['id'] => '4c5c3c08-2b14-9f9c-6cee-542c56cac7b1', ['date_entered'] => '2014-10-01 19:29:32', ....continued for all 24 record items ), [1] => Array ( ['assigned_user_name'] => 'Jason Administrator', ['modified_by_name'] => 'Jason Administrator', ['created_by_name'] => 'Jason Administrator', ['id'] => '4c5c3c08-2b14-9f9c-6cee-542c56cac7b1', ['date_entered'] => '2014-10-01 19:29:32', ....continued for all 24 record items ) ) Current Array Format : Array ( [0] => Array ( [0] => Array ( [name] => assigned_user_name [value] => Jason Administrator ) [1] => Array ( [name] => modified_by_name [value] => Jason Administrator ) [2] => Array ( [name] => created_by_name [value] => Jason Administrator ) [3] => Array ( [name] => id [value] => 4c5c3c08-2b14-9f9c-6cee-542c56cac7b1 ) [4] => Array ( [name] => name [value] => test ) [5] => Array ( [name] => date_entered [value] => 2014-10-01 19:29:32 ) [6] => Array ( [name] => date_modified [value] => 2014-10-01 19:29:32 ) [7] => Array ( [name] => modified_user_id [value] => 1 ) [8] => Array ( [name] => created_by [value] => 1 ) [9] => Array ( [name] => description [value] => ) [10] => Array ( [name] => deleted [value] => 0 ) [11] => Array ( [name] => assigned_user_id [value] => 1 ) [12] => Array ( [name] => chann_channelqms_id_c [value] => ) [13] => Array ( [name] => channelqms [value] => ) [14] => Array ( [name] => design_name [value] => ) [15] => Array ( [name] => design_number [value] => ) [16] => Array ( [name] => overall_height [value] => ) [17] => Array ( [name] => overall_width [value] => ) [18] => Array ( [name] => show_to_customer [value] => 1 ) [19] => Array ( [name] => uploadfile [value] => 2014-09-29_21-57-50.png ) [20] => Array ( [name] => nam_channelletterqms_nam_channelletterqms_designs_name [value] => Test ) [21] => Array ( [name] => price_c [value] => ) [22] => Array ( [name] => shipping_c [value] => ) [23] => Array ( [name] => totalprice_c [value] => ) ) [1] => Array ( [0] => Array ( [name] => assigned_user_name [value] => Jason Administrator ) [1] => Array ( [name] => modified_by_name [value] => Jason Administrator ) [2] => Array ( [name] => created_by_name [value] => Jason Administrator ) [3] => Array ( [name] => id [value] => 86f21f44-4b21-1826-3592-542c59e4be66 ) [4] => Array ( [name] => name [value] => fdtgrfdhg ) [5] => Array ( [name] => date_entered [value] => 2014-10-01 19:41:54 ) [6] => Array ( [name] => date_modified [value] => 2014-10-19 19:30:45 ) [7] => Array ( [name] => modified_user_id [value] => 1 ) [8] => Array ( [name] => created_by [value] => 1 ) [9] => Array ( [name] => description [value] => ) [10] => Array ( [name] => deleted [value] => 0 ) [11] => Array ( [name] => assigned_user_id [value] => 1 ) [12] => Array ( [name] => chann_channelqms_id_c [value] => ) [13] => Array ( [name] => channelqms [value] => ) [14] => Array ( [name] => design_name [value] => design name ) [15] => Array ( [name] => design_number [value] => 313 ) [16] => Array ( [name] => overall_height [value] => 22 ) [17] => Array ( [name] => overall_width [value] => 22 ) [18] => Array ( [name] => show_to_customer [value] => 1 ) [19] => Array ( [name] => uploadfile [value] => 2014-09-29_21-57-50.png ) [20] => Array ( [name] => nam_channelletterqms_nam_channelletterqms_designs_name [value] => Test ) [21] => Array ( [name] => price_c [value] => ) [22] => Array ( [name] => shipping_c [value] => ) [23] => Array ( [name] => totalprice_c [value] => ) ) )
If you can't change it at the source then here is one way (PHP >= 5.5.0 needed for array_column): foreach($design_values as $key => $values) { $result[$key] = array_combine( array_column($values, 'name'), array_column($values, 'value')); } Or possibly, and easier: foreach($design_values as $key => $values) { $result[$key] = array_column($values, 'value', 'name'); } Our use the PHP Implementation of array_column
You should probably create the array you want when making the first array, but if you don't have control over that and just want to conver then something like this should work: $newArray = array(); foreach($oldArray as $row){ $tmp = array(); foreach($row as $values){ $tmp[$values['name']] = $values['value']; } $newArray[] = $tmp; } print_r($newArray);
Function token_get_all not showing any tokens
I've got this simple code to test the output of token_get_all... $arr = token_get_all("<?php $array=array(1,2,3); foreach($array as $key => $value) print($value); ?>"); print("<pre>"); print_r($arr); print("</pre>"); But what ends up being displayed is this: Array ( [0] => Array ( [0] => 372 [1] => 1 ) [1] => = [2] => Array ( [0] => 362 [1] => array [2] => 1 ) [3] => ( [4] => Array ( [0] => 305 [1] => 1 [2] => 1 ) [5] => , [6] => Array ( [0] => 305 [1] => 2 [2] => 1 ) [7] => , [8] => Array ( [0] => 305 [1] => 3 [2] => 1 ) [9] => ) [10] => ; [11] => Array ( [0] => 375 [1] => [2] => 1 ) [12] => Array ( [0] => 322 [1] => foreach [2] => 1 ) [13] => ( [14] => Array ( [0] => 375 [1] => [2] => 1 ) [15] => Array ( [0] => 326 [1] => as [2] => 1 ) [16] => Array ( [0] => 375 [1] => [2] => 1 ) [17] => Array ( [0] => 360 [1] => => [2] => 1 ) [18] => Array ( [0] => 375 [1] => [2] => 1 ) [19] => ) [20] => Array ( [0] => 375 [1] => [2] => 1 ) [21] => Array ( [0] => 266 [1] => print [2] => 1 ) [22] => ( [23] => ) [24] => ; [25] => Array ( [0] => 375 [1] => [2] => 1 ) [26] => Array ( [0] => 374 [1] => ?> [2] => 1 ) ) From everything I've read about token_get_all, I'd expect the [0] key of these arrays to be the token names. What's going on with my code/server that I'm getting this instead? I've also tried doing: $arr = token_get_all(file_get_contents('someOtherValidPHPFile.php')); And I get the same kind of result. I'm using PHP version 5.4.19
Yes the token type is on index 0. This is just a numeric value which identifies the token type. You can then compare them against the following list of token types: List of Parser Tokens You can get the token name by using the token_name() function.
Tokens are defined as constants. E.g. the constant is named T_ARRAY and its value is 362. You can compare the tokens to that constant: if ($token[0] == T_ARRAY) ... If you want to get the readable name, use token_name.
parse xml to mysql
I have a XML feed from which I need to parse some of it and store it into MySQL table, but I'm facing a new kind of XML (I'm not good at this) Here is the XML I'm getting which i'm opening using simplexml_load_file from this address: It's a pubmed journal publication I need to store authorlist and some other, but with a hint on how to access it I can manage. Thanks a lot SimpleXMLElement Object ( [DocSum] => SimpleXMLElement Object ( [Id] => 22064119 [Item] => Array ( [0] => 2011 Dec [1] => SimpleXMLElement Object ( [#attributes] => Array ( [Name] => EPubDate [Type] => Date ) ) [2] => Clin Nucl Med [3] => SimpleXMLElement Object ( [#attributes] => Array ( [Name] => AuthorList [Type] => List ) [Item] => Array ( [0] => Jackson TA [1] => Choong KW [2] => Eng JA [3] => McAneny D [4] => Subramaniam RM [5] => Knapp PE ) ) [4] => Knapp PE [5] => F-18 FDG PET/CT Imaging of Endogenous Cushing Syndrome. [6] => 36 [7] => 12 [8] => e231-2 [9] => SimpleXMLElement Object ( [#attributes] => Array ( [Name] => LangList [Type] => List ) [Item] => English ) [10] => 7611109 [11] => 0363-9762 [12] => 1536-0229 [13] => SimpleXMLElement Object ( [#attributes] => Array ( [Name] => PubTypeList [Type] => List ) [Item] => Journal Article ) [14] => PubMed - in process [15] => ppublish [16] => SimpleXMLElement Object ( [#attributes] => Array ( [Name] => ArticleIds [Type] => List ) [Item] => Array ( [0] => 10.1097/RLU.0b013e3182336360 [1] => 00003072-201112000-00044 [2] => 22064119 [3] => 22064119 [4] => 22064119 ) ) [17] => 10.1097/RLU.0b013e3182336360 [18] => SimpleXMLElement Object ( [#attributes] => Array ( [Name] => History [Type] => List ) [Item] => Array ( [0] => 2011/11/09 06:00 [1] => 2011/11/09 06:00 [2] => 2011/11/09 06:00 ) ) [19] => SimpleXMLElement Object ( [#attributes] => Array ( [Name] => References [Type] => List ) ) [20] => 1 [21] => 0 [22] => Clinical nuclear medicine [23] => SimpleXMLElement Object ( [#attributes] => Array ( [Name] => ELocationID [Type] => String ) ) [24] => 2011 Dec;36(12):e231-2 ) ) )
You can run an XPath on the object like this: $xml->xpath('/DocSum/Item/3/Item');
How can I process this string so I end up with an array that just contains the full name & the associated jpg URL for each entity?
I have the following string which I need to extract the full name plus the URI/URL associated with it into an array for each one. It's not constructed like typical data, so I am unsure how to proceed. I thought explode at first, but there is "garbage" data in the beginning not needed, so I need a way to maybe cleanse the data first? But maybe there is an efficient way of doing this in one or two steps/stages so my code is efficient? After some research I am thinking mb_split() but I am very poor at constructing regex. Need some direction here... In my example below, you can see the data pattern that emerges after the initial "junk". The 3rd "row" for each grouping that forms is where the meat (aka data) that I seek is. The first string in that first grouping, in the 3rd row in the example is "Amanda Grider". This is the full name and its position in the returned data example I am looking for from each grouping. Further along that row is the URI/URL for the jpg image, which is the second piece of data I seek. Everything else as far as I am concerned is garbage and can get tossed. What is the fastest, most efficient way to process this chunk and get the values I seek into an array so i can use this in my work? (BTW, the following code I hand added return characters to make the data more easily understood. In reality, there are no return characters and it presents as one big string) [ [ "tsg.lac", [], [ [ [null,null,"100829745667958569941"], [], ["Amanda Grider",null,null,null,"4b3347c83f0a1","8nwbFHob02C8CmojHF","BoZrAHx801Rz8o3h8k",null,"https://lh3.googleusercontent.com/-zIK8ZN_ZDt8/AAAAAAAAAAI/AAAAAAAAAAA/fsiR92bLDlU/photo.jpg",null,1,"Marina del Rey, CA",null,null,null,0,null,[],null,null,null,""], [] ],[ [null,null,"115014076410206782853"], [], ["VWvortex",null,null,null,"4b13c6667b3c9","JKCGFo_CApJ","JKCGFo_CApJ",null,"//lh6.googleusercontent.com/-X_wSt8nwpOU/AAAAAAAAAAI/AAAAAAAAACQ/R_jcIPcegbM/photo.jpg",null,1,null,null,null,null,0,null,[],[null,"http://WWW.VWVORTEX.COM",null,null,3],null,null,"World's largest Volkswagen enthusiast community and blog."], [] ],[ [null,null,"102608018926739248428"], [], ["Wale",null,null,null,"4b1ded89a3721","JmRxAk","JmRxAk",null,"//lh4.googleusercontent.com/-xyeyjc4Avow/AAAAAAAAAAI/AAAAAAAAABU/SY-9EKeDnhw/photo.jpg",null,1,null,null,null,null,0,null,[],[null,"http://www.ralphfolarin.com/",null,null,6],null,null,""], [] ],[ [null,null,"114161985228080012446"], [], ["The Opus Rhythm Music Blog",null,null,null,"4b177a5207d09","IIJj03C4Iog3HIKMIIJz02xEHnRf01ZxFnB","IIJj03C4Iog3HIKMIIJz02xEHnRf01ZxFnB",null,"//lh5.googleusercontent.com/-4QRl1IgDCLU/AAAAAAAAAAI/AAAAAAAAABI/pVoxTQ7SH8Y/photo.jpg",null,1,null,null,null,null,0,null,[],[null,"http://www.bacchusentertainment.com",null,null,6],null,null,"We are the team music blog of Bacchus Entertainment"], [] ],[ [null,null,"114645267718535118440"], [], ["Jalopnik",null,null,null,"4b12fccb6f809","DHRxFoK0Cng","DHRxFoK0Cng",null,"//lh6.googleusercontent.com/-_M1nn9mKyY8/AAAAAAAAAAI/AAAAAAAAABI/aXhkyN7cuuk/photo.jpg",null,1,null,null,null,null,0,null,[],[null,"http://jalopnik.com/",null,null,3],null,null,"Jalopnik: Drive Free or Die"], [] ],[ [null,null,"105503202599719238167"], [], ["Audi USA",null,null,null,"4b14db7535e99","8owhCkGEHmR","8owhCkGEHmR",null,"//lh3.googleusercontent.com/-mHHyVhWfARE/AAAAAAAAAAI/AAAAAAAAAC4/Qn0lYbilT8M/photo.jpg",null,1,null,null,null,null,0,null,[],[null,"http://www.audiusa.com","(800) 822-2834",null,3],null,null,"Progress is social media, and listening, and fans, and Google+. So here we are."], [] ],[ [null,null,"104108787932235341403"], [], ["Audi Sport",null,null,null,"4b23243c864b1","8owhCkGAGJC8IF","8owhCkGAGJC8IF",null,"//lh4.googleusercontent.com/-jGBNL9dbwYs/AAAAAAAAAAI/AAAAAAAAAUA/pgsAqvaX8XM/photo.jpg",null,1,null,null,null,null,0,null,[],[null,"http://www.facebook.com/AudiSportPage",null,null,6],null,null,"Unofficial Audi Sport fan page, not affiliated with or endorsed by Audi AG."], [] ],[ [null,null,"106689856342933829975"], [], ["Volkswagen USA",null,null,null,"4b20ca9b7fa69","JJBxDohI8nBjFFGEHmR","JJBxDohI8nBjFFGEHmR",null,"//lh5.googleusercontent.com/-i3MO9CsymQ8/AAAAAAAAAAI/AAAAAAAAAB4/ddmTW3D8s20/photo.jpg",null,1,null,null,null,null,0,null,[],[null,"http://www.vw.com","(800) 822-8987",null,3],null,null,"Take a look around, kick the tires, ask questions and get to know our community."], [] ],[ [null,null,"115425298803319911308"], [], ["Internal Frequency",null,null,null,"4b177b6d46119","Co4CAo_08no3BJZjGowjFHhM","Co4CAo_08no3BJZjGowjFHhM",null,"//lh4.googleusercontent.com/-lZeecuGL3Ig/AAAAAAAAAAI/AAAAAAAAABk/Afv5eGuBzUM/photo.jpg",null,1,null,null,null,null,0,null,[],[null,"http://www.internalfrequency.com",null,null,6],null,null,"The 1st hand ups-and-downs of the CEO of an up-and-coming entertainment label in Southern California"], [] ],[ [null,null,"101358795463286919640"], [], ["Music Think Tank",null,null,null,"4b1947fea8251","EoxACmg3IIJrFIg3IHS0Dk","EoxACmg3IIJrFIg3IHS0Dk",null,"//lh4.googleusercontent.com/-B2KTfl4uNyE/AAAAAAAAAAI/AAAAAAAAACM/N955ZhPV08E/photo.jpg",null,1,null,null,null,null,0,null,[],[null,"http://www.musicthinktank.com",null,null,6],null,null,"Where the music industry speaks out loud. Create the Chaos."], [] ] ] ] ] UPDATE: So I stumbled on something and discovered the data is in fact valid JSON, does get decoded and passed back but still something odd and seems very complex (too complex for what I need). I use json_decode() to prase the data, which then is assigned to the variable $jsondata. When I added the following immediately after that: print_r ( print_r($jsondata)); I got this (I added return characters so it makes more sense and can be easily read): Array ( [0] => Array ( [0] => tsg.lac [1] => Array () [2] => Array ( [0] => Array ( [0] => Array ( [0] => [1] => [2] => 100829745667958569941 ) [1] => Array ( ) [2] => Array ( [0] => Amanda Grider [1] => [2] => [3] => [4] => 4b33843806e03 [5] => 8nwbFHob02C8CmojHF [6] => BoZrAHx801Rz8o3h8k [7] => [8] => https://lh3.googleusercontent.com/-zIK8ZN_ZDt8/AAAAAAAAAAI/AAAAAAAAAAA/fsiR92bLDlU/photo.jpg [9] => [10] => 1 [11] => Marina del Rey, CA [12] => [13] => [14] => [15] => 0 [16] => [17] => Array ( ) [18] => [19] => [20] => [21] => ) [3] => Array ( ) ) [1] => Array ( [0] => Array ( [0] => [1] => [2] => 115014076410206782853 ) [1] => Array ( ) [2] => Array ( [0] => VWvortex [1] => [2] => [3] => [4] => 4b13c6667b3c9 [5] => JKCGFo_CApJ [6] => JKCGFo_CApJ [7] => [8] => //lh6.googleusercontent.com/-X_wSt8nwpOU/AAAAAAAAAAI/AAAAAAAAACQ/R_jcIPcegbM/photo.jpg [9] => [10] => 1 [11] => [12] => [13] => [14] => [15] => 0 [16] => [17] => Array ( ) [18] => Array ( [0] => [1] => http://WWW.VWVORTEX.COM [2] => [3] => [4] => 3 ) [19] => [20] => [21] => World's largest Volkswagen enthusiast community and blog. ) [3] => Array ( ) ) [2] => Array ( [0] => Array ( [0] => [1] => [2] => 102608018926739248428 ) [1] => Array ( ) [2] => Array ( [0] => Wale [1] => [2] => [3] => [4] => 4b1ded89a3721 [5] => JmRxAk [6] => JmRxAk [7] => [8] => //lh4.googleusercontent.com/-xyeyjc4Avow/AAAAAAAAAAI/AAAAAAAAABU/SY-9EKeDnhw/photo.jpg [9] => [10] => 1 [11] => [12] => [13] => [14] => [15] => 0 [16] => [17] => Array ( ) [18] => Array ( [0] => [1] => http://www.ralphfolarin.com/ [2] => [3] => [4] => 6 ) [19] => [20] => [21] => ) [3] => Array ( ) ) [3] => Array ( [0] => Array ( [0] => [1] => [2] => 114161985228080012446 ) [1] => Array ( ) [2] => Array ( [0] => The Opus Rhythm Music Blog [1] => [2] => [3] => [4] => 4b177a5207d09 [5] => IIJj03C4Iog3HIKMIIJz02xEHnRf01ZxFnB [6] => IIJj03C4Iog3HIKMIIJz02xEHnRf01ZxFnB [7] => [8] => //lh5.googleusercontent.com/-4QRl1IgDCLU/AAAAAAAAAAI/AAAAAAAAABI/pVoxTQ7SH8Y/photo.jpg [9] => [10] => 1 [11] => [12] => [13] => [14] => [15] => 0 [16] => [17] => Array ( ) [18] => Array ( [0] => [1] => http://www.bacchusentertainment.com [2] => [3] => [4] => 6 ) [19] => [20] => [21] => We are the team music blog of Bacchus Entertainment ) [3] => Array ( ) ) [4] => Array ( [0] => Array ( [0] => [1] => [2] => 114645267718535118440 ) [1] => Array ( ) [2] => Array ( [0] => Jalopnik [1] => [2] => [3] => [4] => 4b12fccb6f809 [5] => DHRxFoK0Cng [6] => DHRxFoK0Cng [7] => [8] => //lh6.googleusercontent.com/-_M1nn9mKyY8/AAAAAAAAAAI/AAAAAAAAABI/aXhkyN7cuuk/photo.jpg [9] => [10] => 1 [11] => [12] => [13] => [14] => [15] => 0 [16] => [17] => Array ( ) [18] => Array ( [0] => [1] => http://jalopnik.com/ [2] => [3] => [4] => 3 ) [19] => [20] => [21] => Jalopnik: Drive Free or Die ) [3] => Array ( ) ) [5] => Array ( [0] => Array ( [0] => [1] => [2] => 105503202599719238167 ) [1] => Array ( ) [2] => Array ( [0] => Audi USA [1] => [2] => [3] => [4] => 4b14db7535e99 [5] => 8owhCkGEHmR [6] => 8owhCkGEHmR [7] => [8] => //lh3.googleusercontent.com/-mHHyVhWfARE/AAAAAAAAAAI/AAAAAAAAAC4/Qn0lYbilT8M/photo.jpg [9] => [10] => 1 [11] => [12] => [13] => [14] => [15] => 0 [16] => [17] => Array ( ) [18] => Array ( [0] => [1] => http://www.audiusa.com [2] => (800) 822-2834 [3] => [4] => 3 ) [19] => [20] => [21] => Progress is social media, and listening, and fans, and Google+. So here we are. ) [3] => Array ( ) ) [6] => Array ( [0] => Array ( [0] => [1] => [2] => 104108787932235341403 ) [1] => Array ( ) [2] => Array ( [0] => Audi Sport [1] => [2] => [3] => [4] => 4b23243c864b1 [5] => 8owhCkGAGJC8IF [6] => 8owhCkGAGJC8IF [7] => [8] => //lh4.googleusercontent.com/-jGBNL9dbwYs/AAAAAAAAAAI/AAAAAAAAAUA/pgsAqvaX8XM/photo.jpg [9] => [10] => 1 [11] => [12] => [13] => [14] => [15] => 0 [16] => [17] => Array ( ) [18] => Array ( [0] => [1] => http://www.facebook.com/AudiSportPage [2] => [3] => [4] => 6 ) [19] => [20] => [21] => Unofficial Audi Sport fan page, not affiliated with or endorsed by Audi AG. ) [3] => Array ( ) ) [7] => Array ( [0] => Array ( [0] => [1] => [2] => 106689856342933829975 ) [1] => Array ( ) [2] => Array ( [0] => Volkswagen USA [1] => [2] => [3] => [4] => 4b20ca9b7fa69 [5] => JJBxDohI8nBjFFGEHmR [6] => JJBxDohI8nBjFFGEHmR [7] => [8] => //lh5.googleusercontent.com/-i3MO9CsymQ8/AAAAAAAAAAI/AAAAAAAAAB4/ddmTW3D8s20/photo.jpg [9] => [10] => 1 [11] => [12] => [13] => [14] => [15] => 0 [16] => [17] => Array ( ) [18] => Array ( [0] => [1] => http://www.vw.com [2] => (800) 822-8987 [3] => [4] => 3 ) [19] => [20] => [21] => Take a look around, kick the tires, ask questions and get to know our community. ) [3] => Array ( ) ) [8] => Array ( [0] => Array ( [0] => [1] => [2] => 115425298803319911308 ) [1] => Array ( ) [2] => Array ( [0] => Internal Frequency [1] => [2] => [3] => [4] => 4b177b6d46119 [5] => Co4CAo_08no3BJZjGowjFHhM [6] => Co4CAo_08no3BJZjGowjFHhM [7] => [8] => //lh4.googleusercontent.com/-lZeecuGL3Ig/AAAAAAAAAAI/AAAAAAAAABk/Afv5eGuBzUM/photo.jpg [9] => [10] => 1 [11] => [12] => [13] => [14] => [15] => 0 [16] => [17] => Array ( ) [18] => Array ( [0] => [1] => http://www.internalfrequency.com [2] => [3] => [4] => 6 ) [19] => [20] => [21] => The 1st hand ups-and-downs of the CEO of an up-and-coming entertainment label in Southern California ) [3] => Array ( ) ) [9] => Array ( [0] => Array ( [0] => [1] => [2] => 101358795463286919640 ) [1] => Array ( ) [2] => Array ( [0] => Music Think Tank [1] => [2] => [3] => [4] => 4b1947fea8251 [5] => EoxACmg3IIJrFIg3IHS0Dk [6] => EoxACmg3IIJrFIg3IHS0Dk [7] => [8] => //lh4.googleusercontent.com/-B2KTfl4uNyE/AAAAAAAAAAI/AAAAAAAAACM/N955ZhPV08E/photo.jpg [9] => [10] => 1 [11] => [12] => [13] => [14] => [15] => 0 [16] => [17] => Array ( ) [18] => Array ( [0] => [1] => http://www.musicthinktank.com [2] => [3] => [4] => 6 ) [19] => [20] => [21] => Where the music industry speaks out loud. Create the Chaos. ) [3] => Array ( ) ) ) ) ) 1 Now that is ALOT of arrays! Not only that, I only require the super nested array [2] where the name starts and of that values [0] & [8] only! Then I get an error when this next line (below) runs but I am less concerned with that, I want to know how can I trim down this data so it doesn't become such a memory hog.... $visiblepeople = $jsondata[2];
To me this looks like JSON ( http://www.json.org ), and thus, you can use any JSON implementation to parse it. For Python, there's a module called ... json ;-) See http://docs.python.org/library/json.html.