Jump to content

Check string length


thefollower

Recommended Posts

it wont let me do all the symbols though, if i do | or + or = for example even when surrounded by ' ' symbols it is acting like its waiting for me to do something with it rather than class it as a char...

 

Only these ones work:

 

$remove = array ('#', '?', '$', '*', '"', ';', ':', '~', '!', '£', '%', '^', '&', '(', ')', ']', '[', '{', '}', '<', '>', ',', '.', '/', '`', '¬', '_');
$count = strlen(str_replace ($remove, '', $NewCode));

 

Not all of them are there as you can see :(

Link to comment
https://forums.phpfreaks.com/topic/74806-check-string-length/#findComment-378288
Share on other sites

here is another way...

 

function Alphanumeric($data) {
   $NewString='';
   preg_match_all("/[a-zA-Z0-9]/", $data, $_);
   for ($i=0;$i < count($_[0]);$i++) $NewString .= str_replace(" ", "", $_[0][$i]);
   return $NewString . ' ' . $i;
}

echo Alphanumeric('test+TEST123=tEsT_');

 

the result will show only alphanumeric characters and the size of the string will be appended to it, the output of the string used in this example would be: testTEST123tEsT 15

 

ok everyone already helped but i couldn't resist!^^ pweaase forgive me! :-[

 

Link to comment
https://forums.phpfreaks.com/topic/74806-check-string-length/#findComment-378332
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.