Input is to be taken from a-z or A-Z. We need to h

2019-09-25 10:49发布

Input is to be taken from a-z or A-Z and the input ends when we give a star(*). We need to have the first and last Capital letters of that input characters as the output. also, we should show the input we have taken each time. N.B. We take the inuputs character by character, not as a string.

Test case 1: input: aAbCcP* output: AP

Test case 2: input: ZabCBc* output: ZB

标签: emu8086
1条回答
\"骚年 ilove
2楼-- · 2019-09-25 11:12
    $test1="aAbCcP*";
    $test="ZabCBc*";
    $i=0;
    $a=[];
    $final_string="";
    while(!empty($test[$i])){ 
        if(ctype_upper($test[$i])){
            $final_string=$test[$i];
            array_push($a,$final_string);
        }
        $i++;
  }
  $first = reset($a);
$last = end($a);

  echo  $first. $last;
查看更多
登录 后发表回答