日期:2014-05-17 浏览次数:20501 次
function foo($s) {
$dict = array_flip(explode(',', '/,monday,tuesday,wednesday,thursday,friday,saturday,sunday'));
$dict['/'] = ',';
return strtr(strtolower($s), $dict);
}
echo foo('Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday');
function foo($s) {
$array=array('monday'=>1,
'tuesday'=>2,
'wednesday'=>3,
'thursday'=>4,
'friday'=>5,
'saturday'=>6,
'sunday'=>7,
'/'=>',',' '=>',');
return strtr(strtolower($s), $array);
}
echo foo('Monday Tuesday Wednesday/Thursday/Friday/Saturday/Sunday');
function foo($s) {
$array= array('monday' => 1,
'tuesday' => 2,
'wednesday'=> 3,
'thursday' => 4,
'friday' => 5,
'saturday' => 6,
'sunday' => 7,
);
$sa = preg_split('/\W/',strtolower($s));
$arr = array();
foreach ($sa as $v) {
if(is_numeric($v)) {
$t = array_values($array);
$arr[] = $t[$v-1];
}
else if (isset($array[$v])) {
$arr[] = $array[$v];
}
else {
foreach ($array as $k1 => $v1 ) {
if ( substr($k1, 0, 4) == $v ) {
$arr[] = $v1; break;
&nb