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

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive