<?php $array = array("1" => "0", "2" => "5", "5" => "7", "1C" => "0", "2C" => "5", "5C" => "10", "1S" => "15", "5S" => "20"); $keyContainsC = []; array_walk($array, function ($value, $key) use (&$keyContainsC) { if (strpos($key, 'C') !== false) $keyContainsC[$key] = $value; }); print_r($keyContainsC); array_walk($array, function ($value, $key) use (&$result) { if (strpos($key, 'C') !== false) $result['C'][$key] = $value; if (strpos($key, 'S') !== false) $result['S'][$key] = $value; if (strpos($key, 'C') === false && strpos($key, 'S') === false) $result['NR'][$key] = $value; }); print_r($result['S']);
You have javascript disabled. You will not be able to edit any code.