Find the character in the string

technical talkiess
0

Find the character in the string 

<!DOCTYPE html>

<html>

<body>


<?php

$string = "PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages and it's so easy to learn.";

$length = strlen($string);

$check = ['v','i','s','h','a','l'];

$character_array = [];

for($i=0;$i<$length;$i++){

$ch = substr($string,$i,1);

if(in_array($ch,$check)){

if($character_array[$ch]){

      $character_array[$ch]++;

    }else{

      $character_array[$ch]= 1;

    }

}


}

ksort($character_array);


print_r($character_array);

?> 


</body>

</html>


Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)