Jump to content

[SOLVED] strip certain characters


gevans

Recommended Posts

Hey guys,

 

I'm part way through building a cms. The cms can make pages that are redirected using .htaccess file

 

All the URL are as follows http://www.mydomain.com/an_added_page

 

htaccess takes an_added_page and loads=> index.php?p=an_added_page

 

The filename is made from the page title, so An Added Page gets converted to an_added_page and stored.

 

I want the users to be able to write anything in the page title, but store a version of it with [a-z0-9_] what's the best way to do this??

 

<?php
//Example
$title= "This's the page title!";

//Desired string = "this_s_the_page_title"

if(!ereg("^[a-zA-Z0-9_]+$", $title)){
//string isn't fine, need to strip out anything that isn't a-z, 0-9 or and udnerscore
} else {
//string's fine
$title = str_to_lower($title);
}
?>

 

Hope all that makes sense......

Link to comment
https://forums.phpfreaks.com/topic/133647-solved-strip-certain-characters/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.