Hi,
can you give me a php function that will convert
a given string into letters and numbers only?
not including symbols..?
I have tried base6_encode but it has + and / included when
I encode the string...
All I want is only numbers and letters...
Please reply if you know any....
thanks...
encode a string
Moderator: General Moderators
Re: encode a string
You should use regular expressions:
You can also create a very simple function:
Code: Select all
<?php
$string = 'asdasf we*(^789shfjkasdhfh&*%56 95';
//with white spaces
$pattern = '/[^a-zA-Z0-9\s]/u';
echo preg_replace($pattern, '', (string) $string);
//only numbers and letters
$pattern = '/[^a-zA-Z0-9]/u';
echo preg_replace($pattern, '', (string) $string);
Code: Select all
function alnumFilter($string){
$pattern = '/[^a-zA-Z0-9]/u';
return preg_replace($pattern, '', (string) $string);
}