I've got the following Array...
$array = array(
"1" => "0",
"2" => "5",
"5" => "7",
"1C" => "0",
"2C" => "5",
"5C" => "10",
"1S" => "15",
"5S" => "20"
);
Is there an easy way to shorten the array to only show the key's that contain C? Or split the array where 1 array has the C's and 1 array has the S's and 1 array for just numbers. I don't mind if the new array(s) have different names.
The number of repetitions for just numbers, C's, and S's will be different based on information returned from database. So I cannot use array_slice amd array_chunk in the default of how they were designed to perform.
I know I can use a foreach
loop to loop through the key => value
pairs and us strpos()
to find C, S, and just numbers; however, I was hoping there may be a better way via an array function.