Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 25th March 2006, 02:54
danf.1979 danf.1979 is offline
Senior Member
 
Join Date: Dec 2005
Location: Chile
Posts: 247
Thanks: 4
Thanked 3 Times in 2 Posts
Send a message via MSN to danf.1979
Default Problem with ctype_alnum and spanish characters

I have this on my source code, but it does not work:
PHP Code:
setlocale(LC_ALL'es_CL.utf8');

// Do add result
$clean = array();
if (isset(
$_POST["name"]) && !empty($_POST["name"]) && ctype_alnum($_POST["name"]) && strlen($_POST["name"]) < 50) {
        
$mysql["name"] = clean_input($_POST["name"]);

And the locale is there:
Code:
dan@www:~$ locale -a | grep CL
es_CL.utf8
I want ctype_alnum to recognize characters like ,,, etc... is this possible? someone has done it?
Thanks.
Reply With Quote
Sponsored Links
  #2  
Old 9th April 2006, 09:44
danf.1979 danf.1979 is offline
Senior Member
 
Join Date: Dec 2005
Location: Chile
Posts: 247
Thanks: 4
Thanked 3 Times in 2 Posts
Send a message via MSN to danf.1979
 
Default

This is an alternative solution:

PHP Code:
// _ctype_alnum accepting spanish chars
function _ctype_alnum($string)
{
    
$convert = array(
                    
""=>"a"""=>"e"""=>"i"""=>"o"""=>"u"""=>"n",
                    
""=>"A"""=>"E"""=>"I"""=>"O"""=>"U"""=>"N"
                    
);
    
$string strtr($string$convert);
    return 
ctype_alnum($string);


Last edited by danf.1979; 18th April 2006 at 05:38.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 00:13.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.