For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Thursday, March 12, 2015

Remove special character in php

You have a website and in that website you have lot of form for user. user fill many data via that forms. some time user feed special characters that are unreadable. so how to remove that special characters before inserting in data base? here is the few lines of code that will do it.

<?php
$input = "Fóø Bår this is the php form data ?A?B?C?D //\\?......!@#$%^&*()_+"; // input text
$output = iconv("utf-8", "ascii//TRANSLIT//IGNORE", $input);
$output =  preg_replace("/^'|[^A-Za-z0-9\s-]|'$/", '', $output); // Remove utf-8 special characters except blank spaces
echo $output; // Results
?>
Share:

0 comments:

Post a Comment

Unable to resolve <website url> Try checking the for validity Google Pagespeed Insights

Unable to resolve <website url> Try checking the for validity Google Pagespeed Insights   You have a website and want to test it'...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive