Output 20 consecutive odd, array splicing merge, String cut

Source: Internet
Author: User

<?PHP//Job 1 output 20 consecutive oddfunctionOdd$length){    $arr=Array(); $a=-1;  for($i= 0;$i<$length;$i++){        $a+ = 2; $arr[$i] =$a; }    Echo"<pre>"; Print_r($arr); Echo"</pre>";} Odd (20);? ><?PHP//job two//construct a contiguous array of natural numbersfunctionNum$length){    $arr=Array(); $a= 0;  for($i= 0;$i<$length;$i++){        $a+ = 1; $arr[$i] =$a; }    return $arr;}//The first parameter is the length of the array, and the second argument is the length of the end of the intercept.functionOPRT ($a,$b){    $arr 1= num ($a); //The remainder of the intercept is the last five items of the array, that is, $ARR1 is the end five    $b=Count($arr 1)-5;$arr 2=Array_splice($arr 1, 0,$b);//arr2:1, 2, 3, 4, 5    $res=Array_merge($arr 1,$arr 2);//Arr1:6, 7, 8, 9, ten    Echo"<pre>"; Print_r($res); Echo"</pre>";} OPRT (20, 5);? ><?PHP//job three turn Close_door into ClosedoorfunctionChange$str){    $arr=Explode("_",$str); foreach($arr  as $key=$value){        $tmp=Ucfirst($value); $tarr[] =$tmp; }    $tarr=implode("",$tarr); Echo $tarr;} Change ("Close_door");?>

Output 20 consecutive odd, array splicing merge, String cut

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.