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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.