Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- array(5) {
- [01081] => Array(3){
- [id] => 2
- [Mark] => 420
- [lastUpdated] => 2010-03-17 15:44:12
- [dataNext] => Array(2){
- [more1] => 54
- [More2] => 54
- }
- }
- [00358] => Array(3){
- [id] => 6
- [Mark] => 500
- [lastUpdated] => 2010-03-17 15:44:12
- [dataNext] => Array(2){
- [more1] => 54
- [More2] => 54
- }
- }
- [00277] => Array(3){
- [id] => 3
- [Mark] => 400
- [lastUpdated] => 2010-03-17 15:44:12
- [dataNext] => Array(2){
- [more1] => 54
- [More2] => 54
- }
- }
- [00357] => Array(3){
- [id] => 1
- [Mark] => 500
- [lastUpdated] => 2010-03-17 15:44:12
- [dataNext] => Array(2){
- [more1] => 54
- [More2] => 54
- }
- }
- }
- array(3) {
- [0400] => Array(1){
- [count] => 1
- [element] => '00277'
- }
- [0420] => Array(1){
- [count] => 1
- [element] => '01081'
- }
- [0500] => Array(1){
- [count] => 2
- [element] =>'00357,00358'
- }
- }
- $arr = [
- '01081' => [
- 'id' => 2,
- 'Mark' => 420,
- 'lastUpdated' => '2010-03-17 15:44:12',
- 'dataNext' => [
- 'more1' => 54,
- 'More2' => 54,
- ]
- ],
- '00358' => [
- 'id' => 6,
- 'Mark' => 500,
- 'lastUpdated' => '2010-03-17 15:44:12',
- 'dataNext' => [
- 'more1' => 54,
- 'More2' => 54,
- ]
- ],
- '00277' => [
- 'id' => 3,
- 'Mark' => 400,
- 'lastUpdated' => '2010-03-17 15:44:12',
- 'dataNext' => [
- 'more1' => 54,
- 'More2' => 54,
- ]
- ],
- '00357' => [
- 'id' => 1,
- 'Mark' => 500,
- 'lastUpdated' => '2010-03-17 15:44:12',
- 'dataNext' => [
- 'more1' => 54,
- 'More2' => 54,
- ]
- ]
- ];
- $result = [];
- foreach($arr as $id => $data) {
- if (! isset($result[$data['Mark']])) {
- $result[$data['Mark']] = [
- 'count' => 1,
- 'element' => $id
- ];
- } else {
- $result[$data['Mark']]['count']++;
- $result[$data['Mark']]['element'] = $result[$data['Mark']]['element'] .','.$id;
- }
- }
- ksort($result);
- print_r($result);
Add Comment
Please, Sign In to add comment