samedi 3 avril 2021

check string characters in string

Take an input string (via form post) which can contain single-digit numbers, letters, and question marks, and check if there are exactly 2 question marks between every pair of two numbers that add up to 12. If so, return "Yes", otherwise it should return "No". If there aren't any two numbers that add up to 12 in the string, return "No".

For example: if str is "arrb7??5xxbl8??eee4" then your program should return true because there are exactly 2 question marks between 7 and 5, and 2 question marks between 8 and 4 at the end of the string.

enter code here

<?php 
    $value = $_POST['temp'];
    $len = strlen($value);
    // $splt = explode(",",$value);  
    

    // var_dump($splt);
    // foreach($splt as $result)
    // {
    //     echo $result ."<br>";
    // }
    $i=0; 
    strpos($value[i]);
    if(is_numeric($value)&& $len < 12)
    {
        echo  $value;

    }    

    else
    {
           echo 'no';
    }


//  $temp = explode($value);
    // if($value == )
    // is_numeric($value);
enter code here



Aucun commentaire:

Enregistrer un commentaire