how to check the same value in array in php -
i have array days key , timings values:
array( [mon] => 9:00-10:00,12:00-15:00,10:00-14:00 [tue] => 9:00-10:00,12:00-15:00 [wed] => 9:00-10:00,12:00-15:00 [thu] => 9:00-10:00,12:00-15:00 [fri] => 9:00-10:00,12:00-15:00 [sat] => 9:00-10:00,12:00-15:00 [sun] => 10:00-14:00 )
and want same array in way:
array( [mon] => 9:00-10:00,12:00-15:00,10:00-14:00 [tue/wed/thu/fri/sat] => 9:00-10:00,12:00-15:00 [sun] => 10:00-14:00 )
any 1 can me on this?
$temp = array(); foreach ($array $day => $value) { if (!in_array($value, $temp)) { $temp[] = $value; $result[implode("/",array_keys($array,$value))] = $value; } }
see demo.
Comments
Post a Comment