How to count the number of characters in a string without spaces and special characters in PHP

1 Answer

0 votes
$str = "8php java 123 c &c++.";

$result  = strlen(preg_replace("/[^A-Za-z]/", "", $str));
  
echo $result;


/*
run:

9

*/

 



answered Sep 15, 2024 by avibootz
...