I have the array like given below
Array ( [id] => 1 [businessunit_id] => 1 [service_name] => dropbox [file_path] => /home/john/Desktop/GoogleDrive/alfresco_details.txt [attribute] => App key [value] => wlvii0k1bdm5lk8 )
Array ( [id] => 1 [businessunit_id] => 1 [service_name] => dropbox [file_path] => /home/john/Desktop/GoogleDrive/alfresco_details.txt [attribute] => App secret [value] => eui9d7p62qvxt78 )
Array ( [id] => 1 [businessunit_id] => 1 [service_name] => dropbox [file_path] => /home/john/Desktop/GoogleDrive/alfresco_details.txt [attribute] => Accesstoken [value] => IwSMaEYuDMAAAAAAAAAAC5jf8SyEXQUdf65xCrzFDbqrtlVyPQoJ7OBV1BRyHqqp )
Array ( [id] => 2 [businessunit_id] => 2 [service_name] => s3 [file_path] => /home/john/Desktop/GoogleDrive/alfresco_details.txt [attribute] => AWS_ACCESS_KEY_ID [value] => xxx )
Array ( [id] => 2 [businessunit_id] => 2 [service_name] => s3 [file_path] => /home/john/Desktop/GoogleDrive/alfresco_details.txt [attribute] => AWS_SECRET_ACCESS_KE [value] => xxxxxx )
I want it to convert like below
Array ( [id] => 1 [businessunit_id] => 1 [service_name] => dropbox [file_path] => /home/john/Desktop/GoogleDrive/alfresco_details.txt array([App key] =>wlvii0k1bdm5lk8, [App secret] =>eui9d7p62qvxt78, [Accesstoken] =>IwSMaEYuDMAAAAAAAAAAC5jf8SyEXQUdf65xCrzFDbqrtlVyPQoJ7OBV1BRyHqqp ))
Array ( [id] => 2 [businessunit_id] => 2 [service_name] => s3 [file_path] => /home/john/Desktop/GoogleDrive/alfresco_details.txt array([AWS_ACCESS_KEY_ID] => xxx, [AWS_SECRET_ACCESS_KE] =>xxxxxx) )
unable to get the expected result. could you please some one help me out
here is my php code:
while($row = $result->fetch_assoc()) {
$curid = $row['id'];
//$pastid = $curid;
echo '<pre>';
//print_r($row);
if($i == 0){
$newarray[$i]['id'] = $row['id'];
$newarray[$i]['businessunit_id'] = $row['businessunit_id'];
$newarray[$i]['file_path'] = $row['file_path'];
$newarray[$i]['service_name'] = $row['service_name'];
$newarray[$i][$row['attribute']] = $row['value'];
} else {
if($newarray[$i-1]['id'] == $curid){
$newarray[$i-1][$row['attribute']] = $row['value'];
$newarray[$i]['id'] = $row['id'];
} else{
$newarray[$i]['id'] = $row['id'];
$newarray[$i]['businessunit_id'] = $row['businessunit_id'];
$newarray[$i]['file_path'] = $row['file_path'];
$newarray[$i]['service_name'] = $row['service_name'];
$newarray[$i][$row['attribute']] = $row['value'];
}
}
$i++;
}