Remove duplicated matching values from array PHP -
$arrempty =array(); for($i=0;$i<count($courseinfo['olinelist']);$i++){ if(!in_array($courseinfo['olinelist'][$i]['onday'],$arrempty)){ echo "<pre>"; print_r($courseinfo['olinelist']); } } input: array ( [date] => 2016-02-23 [onday] => 1 [session] => morning [start_time] => 08:30:00 [cd_desc] => registration [end_time] => 09:00:00 [name] => fname lname [profile_pic] => 145464959476.jpg ) array ( [date] => 2016-02-23 [onday] => 1 [session] => morning [start_time] => 09:30:00 [cd_desc] => on label vs off label (botox) [end_time] => 09:45:00 [name] => fname lname [profile_pic] => 145464959476.jpg ) array ( [date] => 2016-02-23 [onday] => 2 [session] => morning [start_time] => 09:00:00 [cd_desc] => introduction [end_time] => 09:15:00 [name] => fname lname [profile_pic] => 145464959476.jpg ) array ( [date] => 2016-02-20 [onday] => 2 [session] => morning [start_time] => 01:00:00 [cd_desc] => lunch [end_time] => 02:15:00 [name] => fname lname [profile_pic] => 146.jpg ) output: date => onday => 1 session => start_time => 08:30:00 cd_desc => registration end_time => 09:00:00 name => fname lname profile_pic => 145464959476.jpg date => onday => session => start_time => 09:30:00 cd_desc => on label vs off label (botox) end_time => 09:45:00 name => fname lname profile_pic => 145464959476.jpg date => onday => 2 session => start_time => 09:00:00 cd_desc => introduction end_time => 09:15:00 name => fname lname profile_pic => 145464959476.jpg date => onday => session => start_time => 01:00:00 cd_desc => lunch end_time => 02:15:00 name => fname lname profile_pic => 146.jpg look @ date, onday , session should blank while displaying each loop
what want remove duplicate element values array , keep key blank. have tried use array_unique($myarray) , seem not working. please help!!!
try this:
$arrempty =array(); for($i=0;$i<count($courseinfo['olinelist']);$i++){ if(!in_array($courseinfo['olinelist'][$i]['onday'],$arrempty['onday'])){ $arrempty[] = $courseinfo['olinelist'][$i]; echo "<pre>"; print_r($courseinfo['olinelist'][$i]); } }
Comments
Post a Comment