Create an array using the index values from another array - php

OK here is what I would like to do. I have an array. What i want to do is make another array of the index values from the first one. Take the below I want to create and array from this :
Array (
[identifier] => ID
[label] => HouseNum
[items] => Array (
[0] => Array (
[ID] => 1
[HouseNum] => 17
[AptNum] =>
[Street] => birch glen dr
[City] => Clifton Park
[State] => NY [Zip5] =>
[EID] => E083223
[RequestDate] => 02/05/09
[Status] => In-Qeue
[DateCompleted] =>
[CompletedBy] =>
[ContactName] => Suzy Q
[ContactNumber] => 555-867-5309
[ContactTime] => 9-9 )
)
);
That will end up looking like this :
Array(
[0] => [ID]
[1] => [HouseNum]
[2] => [AptNum]
[3] => [Street]
[4] => [City]
[5] => [State]
[6] => [Zip5]
[7] => [EID]
[8] => [RequestDate]
[9] => [Status]
[10] => [DateCompleted]
[11] => [CompletedBy]
[12] => [ContactName]
[13] => [ContactNumber]
[14] => [ContactTime]
);
Any thoughts on how to achieve this ? I mostly need to know how to get just the index values.

$indexes = array_keys($whatever['items'][0]);
http://us.php.net/manual/en/function.array-keys.php

foreach($items[0] as $idx => $val)
{
$indexes[] = $idx;
}
Or:
$indexes = array_keys($items[0]);

$result = array_keys($input['items'][0]);

Related

Get sum of subarray column for indexed rows

I have an array of customers/people with a subarray of projects pertaining to that customer. Projects come in two types "typeJob" or "typePipeline". I need to sum the values of individual columns in the projects subarray (specifically columns 5, 6, 7 - representing revenue for month 1, month 2, and month 3) by Client.
I have tried various possible avenues including the one below, but I seem to always end up either testing if the condition is satisfied for the array as a whole rather than for each row - or if I go the way of for each loops generate errors because either there's an array/single value mismatch or the condition just doesn't do anything.
Here is what I have tried most recently. It works in the sense that it checks if "typeJob" is in the array but then sums all rows (even those without "typeJob") if "typeJob" is found for any of the Client's projects. I want to exclude rows where "typeJob" is not found.
foreach ($arrays as $row) {
$indexJob = array_search('typeJob', array_column($row['projects'],0));
if ($indexJob !== false) {
$job_total1[$row['Client']] = array_sum(array_column($row['projects'],5));
$job_total2[$row['Client']] = array_sum(array_column($row['projects'],6));
$job_total3[$row['Client']] = array_sum(array_column($row['projects'],7));
}
}
And here is the array:
(
[331] => Array
(
[KeyAccountID] => 1234
[KeyAccountName] => John Lennon
[ClientID] => 9999
[Client] => BBC
[projects] => Array
(
[0] => Array
(
[0] => typePipeline
[1] => 915
[2] => Zyxeldy
[3] =>
[4] =>
[5] => 15000
[6] =>
[7] =>
[8] =>
)
[1] => Array
(
[0] => typeJob
[1] => 956
[2] => Awesome project, Step 1
[3] =>
[4] =>
[5] => 1833.3333
[6] => 1833.3333
[7] => 1833.3333
[8] =>
)
[2] => Array
(
[0] => typePipeline
[1] => 957
[2] => Awesome project, Step 2
[3] =>
[4] =>
[5] => 7000
[6] =>
[7] =>
[8] =>
)
)
)
[344] => Array
(
[KeyAccountID] => 1234
[KeyAccountName] => John Lennon
[ClientID] => 9998
[Client] => ABC
[projects] => Array
(
[0] => Array
(
[0] => typePipeline
[1] => 487
[2] => CRM integration
[3] =>
[4] =>
[5] =>
[6] => 98750
[7] => 98750
[8] =>
)
[1] => Array
(
[0] => typeJob
[1] => 839
[2] => Data Warehouse
[3] =>
[4] =>
[5] =>
[6] => 11643.0601
[7] =>
[8] =>
)
)
)
[350] => Array
(
[KeyAccountID] => 1236
[KeyAccountName] => Ringo Starr
[ClientID] => 9997
[Client] => XYY
[projects] => Array
(
[0] => Array
(
[0] => typeJob
[1] => 867
[2] => Data Mining
[3] =>
[4] =>
[5] => 10000
[6] =>
[7] =>
[8] =>
)
)
)
[351] => Array
(
[KeyAccountID] => 1235
[KeyAccountName] => Poul McCartney
[ClientID] => 9996
[Client] => XYZ
[projects] => Array
(
[0] => Array
(
[0] => typePipeline
[1] => 715
[2] => XYZ, CSM
[3] =>
[4] =>
[5] => 22083.3333
[6] => 22083.3333
[7] => 22083.3333
[8] =>
)
)
)
etc.
You could filter the $row['projects'] array before summing the values:
foreach ($arrays as $row) {
$typeJobs = array_filter($row['projects'], function ($v) { return $v[0] == 'typeJob'; });
$job_total1[$row['Client']] = array_sum(array_column($typeJobs,5));
$job_total2[$row['Client']] = array_sum(array_column($typeJobs,6));
$job_total3[$row['Client']] = array_sum(array_column($typeJobs,7));
}
It may be quicker to just loop through them and keep a running total...
foreach ($arrays as $row) {
$totals = [0,0,0];
foreach ( $row['projects'] as $project ) {
if ( $project[0] == 'typeJob' ) {
$totals[0] += $project[5];
$totals[1] += $project[6];
$totals[2] += $project[7];
}
}
$job_total1[$row['Client']] = $totals[0];
$job_total2[$row['Client']] = $totals[1];
$job_total3[$row['Client']] = $totals[2];
}
it doesn't look as slim as using the array_... methods, but this only processes the array once instead of once for each call.

How to associate values from one array to another array as keys?

So, to simply put it, it looks like this:
Array1:
Array
(
[0] => id
[1] => name
[2] => email
)
Array2:
Array
(
[0] => 1
[1] => paula
[2] => paula#paula.com
[3] => 2
[4] => martin
[5] => martin#google.com
[6] => 3
[7] => kasandra
[8] => kasandra#google.com
[9] => 4
[10] => helena
[11] => helena#google.com
[12] => 5
[13] => sophia
[14] => sophia#google.com
[15] => 6
[16] => denis
[17] => denis#google.com
)
How to make those values from Array1 as keys in Array2 accordingly so that the end result looks like this:
Array
(
[id] => 1
[name] => paula
[email] => paula#paula.com
[id] => 2
[name] => martin
[email] => martin#google.com
[id] => 3
[name] => kasandra
[email] => kasandra#google.com
[id] => 4
[name] => helena
[email] => helena#google.com
[id] => 5
[name] => sophia
[email] => sophia#google.com
[id] => 6
[name] => denis
[email] => denis#google.com
)
you can use a for loop with step 3
$numCoords = count($array2)/3
for ($i = 0; $i < $numCoords; $i++ ){
$array[$i]['id'] = $array2[$i*3];
$array[$i]['name'] = $array2[($i*3)+1];
$array[$i]['email'] = $array2[($i*3)+2];
}
I would go with array_chunk and get used to numeric indexes,
but if you really want to have them as words you may map them:
$keys = [
0 => 'id',
1 => 'name',
2 => 'email'
];
$chunked = array_chunk($array2, $length=3);
$result = array_map(function ($chunk) {
global $keys;
return array_combine($keys, $chunk);
}, $chunked);

PHP Array Remove Duplicates - not Array_Unique

I have a multidimensional array (fake data) in PHP:
Array
(
[0] => Array
(
[pmkSuppliers] => 1
[0] => 1
[Name] => Supplier2
[1] => Supplier2
[Email] => Me#me.com2
[2] => Me#me.com2
[Address] => 624 st
[3] => 624 st
[Phone] => 900-111-1111
[4] => 900-111-1111
[Fax] => 900-111-1112
[5] => 900-111-1112
[TechSupport] => 900-111-1112
[6] => 900-111-1112
[Contact] => Greg
[7] => Greg
[Modified] => 2016-06-07
[8] => 2016-06-07
)
[1] => Array
(
[pmkSuppliers] => 2
[0] => 2
[Name] => Nike
[1] => Nike
[Email] => me#none.com
[2] => me#none.com
[Address] => 4566 way
[3] => 4566 way
[Phone] => 901-206-5555
[4] => 901-206-5555
[Fax] => 901-206-5555
[5] => 901-206-5555
[TechSupport] => 901-206-5445
[6] => 901-206-5445
[Contact] => Brad
[7] => Brad
[Modified] => 2016-06-08
[8] => 2016-06-08
)
)
I want to remove all of the elements with a non int key. So it would look something like this:
Array
(
[0] => Array
(
[0] => 1
[1] => Supplier2
[2] => Me#me.com2
[3] => 624 st
[4] => 900-111-1111
[5] => 900-111-1112
[6] => 900-111-1112
[7] => Greg
[8] => 2016-06-07
)
[1] => Array
(
[0] => 2
[1] => Nike
[2] => me#none.com
[3] => 4566 way
[4] => 901-206-5555
[5] => 901-206-5555
[6] => 901-206-5555
[7] => Brad
[8] => 2016-06-08
)
)
I figure there has to be an easy way to do this, but I'm stuck. I can not use the PHP method array_unique because sometimes the values in my array are the same (like in the second set).
If anyone could point me in the right direction, that would be awesome.
Thanks,
FP
EDIT
This is how I have been doing it, but it seems crude.
foreach ($array as $insideArray) {
foreach ($insideArray as $key => $value) {
if (!is_int($key)) {
echo $value;
}
}
}
In case you are using PDOs, just set the fetch style:
$statement->setFetchMode(PDO::FETCH_NUM);
You can see the difference fetchStyle in manual.
In addition, you can also use
$statement->fetchAll(PDO::FETCH_COLUMN);
Here is an external article 1 and article 2 that discusses, different fetch methods.
foreach ($array as &$arr){
foreach ($arr as $key => $value) {
if (!is_int($key)) {
unset($arr[$key]);
}
}
}

Php array saving values only till 62 indices

I am sending a big array of 130+ indices from ajax to php. But while going to php, if i print, it became a 2D array with indices 63, 63, 6 respectively.
Below is snip
Array
(
[0] => Array
(
[0] => 943900200
[1] => 1297017000
[2] => 1299436200
[3] => 1302114600
[4] => 1304879400
[5] => 1307385000
................
[60] => 1452105000
[61] => 1454869800
[62] => 1457375400
)
[1] => Array
(
[0] => 943900200
[1] => 1297017000
[2] => 1299436200
[3] => 1302114600
[4] => 1304879400
[5] => 1307385000
......
[61] => 1454869800
[62] => 1457289000
)
[2] => Array
(
[0] => 1440441000
[1] => 1443033000
[2] => 1445970600
[3] => 1445970600
[4] => 1447007400
[5] => 1448908200
)
)
But i want them in a single D array...[0]--[127] together. I tried to copy them using foreach aswell. It copies the first 63 indices and stops. Any one please help. Thanks
You must use foreach twice:
INTPUT (example):
Array
(
[0] => Array
(
[0] => 5031750
[1] => 3972258
[2] => 1673731
[3] => 721866
[4] => 4031885
[5] => 1454990
)
[1] => Array
(
[0] => 1115002
[1] => 27608
[2] => 3531620
[3] => 4412066
[4] => 4032217
[5] => 2681734
)
[2] => Array
(
[0] => 3360879
[1] => 5190034
[2] => 3452229
[3] => 5112636
[4] => 628357
[5] => 4299124
)
)
PHP Code:
$output = array();
foreach($input as $key=>$sub){
foreach($sub as $k => $v){
$output[] = $v;
}
}
print_r($output);
Output:
Array
(
[0] => 5031750
[1] => 3972258
[2] => 1673731
[3] => 721866
[4] => 4031885
[5] => 1454990
[6] => 1115002
[7] => 27608
[8] => 3531620
[9] => 4412066
[10] => 4032217
[11] => 2681734
[12] => 3360879
[13] => 5190034
[14] => 3452229
[15] => 5112636
[16] => 628357
[17] => 4299124
)

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.

Categories