就是用php oop来做答吧。
题目如下:
1.有数组如下:[code=php]
$w0=array(0,1,2,3,4,5,6);
$w1=array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
$w2=array("M","T","W","TH","FR","SA","S");
$w3=array("Mon","Tue","Wed","Thu","Fri","Sat","Sun");
$r=array(",","-","\\",".");[/code]
(范围只会取$w0,$w1,$w2,$w3中的一部分;分隔符,只会取$r中的一部分)
请编写一函数,欲可以实现以下功能:
1.当传入数字型字符串时
a.若分隔符为","的,则原值返回。如:"1,3,4";返回其原值"1,3,4";
b.若分隔符为不","的,则将其分隔符,转成",",再输出。如:输入"1-3-4",输出"1,3,4";
2.当传入的是字母型时,
a.若分隔符是","时,要把"M,W",转成"0,2",再输出;
b.若分隔符不是","时,则将其分隔符,转成",";还有把转成对应的数字,再输出。
例:
题目如下:
1.有数组如下:[code=php]
$w0=array(0,1,2,3,4,5,6);
$w1=array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
$w2=array("M","T","W","TH","FR","SA","S");
$w3=array("Mon","Tue","Wed","Thu","Fri","Sat","Sun");
$r=array(",","-","\\",".");[/code]
(范围只会取$w0,$w1,$w2,$w3中的一部分;分隔符,只会取$r中的一部分)
请编写一函数,欲可以实现以下功能:
1.当传入数字型字符串时
a.若分隔符为","的,则原值返回。如:"1,3,4";返回其原值"1,3,4";
b.若分隔符为不","的,则将其分隔符,转成",",再输出。如:输入"1-3-4",输出"1,3,4";
2.当传入的是字母型时,
a.若分隔符是","时,要把"M,W",转成"0,2",再输出;
b.若分隔符不是","时,则将其分隔符,转成",";还有把转成对应的数字,再输出。
例: