Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

Thread: 

remove all characters from string php?

Ads
banner
banner
banner
letsplay Offline referral

Posts: 274
Joined: Jul 2013
Reputation: 1

#1
Senior Member
Any idea how to remove all special characters from the string with PHP? I only want to leave numbers, letters and spaces?
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#2
Support Team
PHP Code:
$string str_replace(' ''-'$string); //replace spaces with dash symbol
$string preg_replace('/[^A-Za-z0-9\-]/'''$string); //remove all but numbers, letters and dash symbol
$string str_replace('-'' '$string); // remove dash symbol
$string trim($string" "); // trim spaces from the beginning and the end 
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
dswtechnologies Offline referral

Posts: 97
Joined: Aug 2015
Reputation: 1

#3
Member
$string = str_replace you can use this code with your own way.
Rapidsoft technologies Offline referral

Posts: 212
Joined: Sep 2015
Reputation: 1

#4
Member
Hi there,
function seo_friendly_url($string){
$string = str_replace(array('[\', \']'), '', $string);
$string = preg_replace('/\[.*\]/U', '', $string);
$string = preg_replace('/&(ampWink?#?[a-z0-9]+;/i', '-', $string);
$string = htmlentities($string, ENT_COMPAT, 'utf-8');
$string = preg_replace('/&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i', '\\1', $string );
$string = preg_replace(array('/[^a-z0-9]/i', '/[-]+/') , '-', $string);
return strtolower(trim($string, '-'));
}





User(s) browsing this thread: 1 Guest(s)