Compare two arrays with unordered items in php -


h have array year,month,day,hour,minute,second (i not know item in array year,month,etc.. it's unordered) have fixed date format like: yy-mm-dd-h-m-s can me.

i wrote code , tried underestand true item.

function ($date,$format) { $year = $month = $day = $hour = $minute = $second = 0;      $format = 'yy-mm-dd-h-m-s'; //string $date   = (1998,12,31,23,44,49) ; // array  $format = explode("-",$format); $date = explode("-",$date);  $date = array_filter(array_unique($date)); $format = array_filter(array_unique($format));  for($i=0;$i<6;$i++) {     if($format[$i] == 'yy') $year = $date[$i];     elseif($format[$i] == 'mm') $month = $date[$i];     elseif($format[$i] == 'dd') $day = $date[$i];     elseif($format[$i] == 'h') $hour = $date[$i];     elseif($format[$i] == 'm') $minute = $date[$i];     elseif($format[$i] == 's') $second = $date[$i];      } echo $year.$month.$day; 

}

but got error:

notice: undefined offset: 1 in /home/admin/domains/example.com/public_html/admin/lib/core.php on line 2058 notice: undefined offset: 1 in /home/admin/domains/example.com/public_html/admin/lib/core.php on line 2059 notice: undefined offset: 1 in /home/admin/domains/example.com/public_html/admin/lib/core.php on line 2060 notice: undefined offset: 1 in /home/admin/domains/example.com/public_html/admin/lib/core.php on line 2061 notice: undefined offset: 1 in

can problem?

the problem array syntax. either need use array(), or enclose items in square brackets [].


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -