i have an array:
$ar = array(
0 => array('id' => '1', 'pname' => 'text'),
1 => array('id' => '2', 'pname' => 'text2'),
2 => array('id' => '2', 'pname' => 'text3'),
3 => array('id' => '3', 'pname' => 'text4'),
4 => array('id' => '4', 'pname' => 'text5'),
5 => array('id' => '4', 'pname' => 'text6'),
6 => array('id' => '4', 'pname' => 'text7'),
);
I want to get array like this:
$result = array(
0 => array('id' => '1', 'pname' => 'text'),
1 => array('id' => '2', 'pname' => array('text2', 'text3')),
3 => array('id' => '3', 'pname' => 'text4'),
4 => array('id' => '4', 'pname' => array('text5', 'text6', 'text7'))
);
need help! how to iterate first array to get result like second array?