Array
(
[0] => Array
(
[user_id] => 0
[activity] => edited
[oid] => 62487513549577588
[article_title] => What if Universal Solutions existed?
[url] => http://127.0.0.1/article.php?id=62487513549577588
[fullname] => Peter Anderson
[photo] => http://127.0.0.1/uploads/0/147885940.png
[link] => http://127.0.0.1/peter.anderson
)

[1] => Array
(
[user_id] => 0
[activity] => edited
[oid] => 776286559146635
[article_title] => Mathematics 101: Introduction
[url] => http://127.0.0.1/article.php?id=776286559146635
[fullname] => Peter Anderson
[photo] => http://127.0.0.1/uploads/0/147885940.png
[link] => http://127.0.0.1/peter.anderson
)

)

Transform this to

Array
(
[0] => Array
(
[user] => Array
(
[user_id] => 0
[fullname] => Peter Anderson
[photo] => http://127.0.0.1/uploads/0/147885940.png
[link] => http://127.0.0.1/peter.anderson
)
[activity] => Array
(
[activity] => edited
)
[article] => Array
(
[oid] => 776286559146635
[url] => http://127.0.0.1/article.php?id=776286559146635
[article_title] => Mathematics 101: Introduction
)
)
)
This is what

Solution:

foreach($items as $item){
$user[‘user_id’] = $item[‘user_id’];
$user[‘fullname’] = $item[‘fullname’];
$user[‘photo’] = $item[‘photo’];
$user[‘link’] = $item[‘link’];

$activity[‘activity’] = $item[‘activity’];

$article[‘oid’] = $item[‘oid’];
$article[‘url’] = $item[‘url’];
$article[‘article_title’] = $item[‘article_title’];

$result[] = array(
‘user’ => $user,
‘activity’ => $activity,
‘article’ => $article
);
}

print_r($result);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s