拆分/子串控阵列 - PHP

I've been smashing my head the last few days, because I haven't been able to create a solution for my problem.

I have an array that looks like this:

[0] => {"count": 1038, "previous": null, "results": [{"data_source": "f31904c94a72490e8fa5750399a14e44", "uuid": "acbb6a8790604ac9916772f51729e69a", "reference": "2015-08-28-xxx@xxx.xx", "value": "0.0000", "member": "a7cab5fa045d44beb72da3ea26e6a49c", "HPSalesBudget": "1.00", "team": null, "date": "2015-08-28T00:00:00"}
[1] => {"data_source": "f31904c94a72490e8fa5750399a14e44", "uuid": "5ba77c689aba48f8ab845c9578b96d1d", "reference": "2015-08-28-xxxx@xxx.xx", "value": "0.0000", "member": "477039a270d841aaa87a5578ee034d60", "HPSalesBudget": "1.00", "team": null, "date": "2015-08-28T00:00:00"}

What I want is to remove the first part of the array

[0] => {"count": 1038, "previous": null, "results": 

And make and array that looks like this:

Array
(
[0] => Array
(
[data_source] => f31904c94a72490e8fa5750399a14e44
[uuid] => acbb6a8790604ac9916772f51729e69a
[reference] => 2015-08-28-xxx@xxx.xx
[value] => 0.0000
[member] => a7cab5fa045d44beb72da3ea26e6a49c
[HPSalesBudget] => 1.00
[team] => null
[date] => 2015-08-28T00:00:00
)

[1] => Array
(
[data_source] => f31904c94a72490e8fa5750399a14e44
[uuid] => acbb6a8790604ac9916772f51729e69a
[reference] => 2015-08-28-xxx@xxx.xx
[value] => 0.0000
[member] => a7cab5fa045d44beb72da3ea26e6a49c
[HPSalesBudget] => 1.00
[team] => null
[date] => 2015-08-28T00:00:00
)

The only reason why my array is looking like this is because that's the format I get the data in.

I have tried googling the problem but without any luck.

Does anybody have an solution for my problem?

Split your data into lines with something like explode(" ", $data);

Then process the data line by line, strip the first 7 characters of each line, so that your data is only this:

{"count": 1038, "previous": null, "results": [{"data_source": "f31904c94a72490e8fa5750399a14e44", "uuid": "acbb6a8790604ac9916772f51729e69a", "reference": "2015-08-28-xxx@xxx.xx", "value": "0.0000", "member": "a7cab5fa045d44beb72da3ea26e6a49c", "HPSalesBudget": "1.00", "team": null, "date": "2015-08-28T00:00:00"}

Then use json_decode on each line.

From there, it's easy to get the data in the format you need:

$result = array();
$result[] = $json['results'];

I guess the code should look like this:

$result = array();
$lines = explode("
", $data);
foreach ($lines as $line) {
    $line = substr($line, 7);
    $json = json_decode($line, true);
    $result[] = $json['results'];
}

Try this:

     $result = json_decode((your_json), true); //decode your json to array

     $newArr = [];
    foreach($result['results'] as $key => $val) {
      $newArr[] = ['data_source'=> $val['data_source']
                    'uuid' => $val['uuid'], 
                    'reference' => $val['reference'],
                    'value' => $val['value'],
                    'member' => $val['member'],
                    'HPSalesBudget' => $val['HPSalesBudget'],
                     'team' => $val['team'],
                     'date'=> $val['date']] ;
     }
     print_r($newArr);

Should be as simple as that:

$myarray[0] = $myarray[0]["results"];