preg_match question

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
kyle04
New php-forum User
New php-forum User
Posts: 94
Joined: Sat Jul 07, 2012 1:36 pm

Wed Oct 03, 2012 3:12 pm

Code: Select all

if(
  preg_match('/[^a-zA-Z]/', stripslashes(trim($_POST['city'])))
){
// nasty characters
}  

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Thu Oct 04, 2012 3:30 pm

Code: Select all

<?php 
$city = "1test1";
$pattern = '[\d]';
$city = preg_replace($pattern,'',$city);
echo $city;
?>

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests