Splitting an array into multiple arrays according to a value

1
2
$oldArray = data;
$newArray = array();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Splitting an array containing objects and grouping it into many arrays according to a key. Like if we have an array containing 5 people; 3 are doctors and 2 are engineers. Splitting it to two arrays each contain people belonging to that profession then grouping it back again into one array containing two arrays!

1 Response

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.