/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Removing Special Characters (Non Alphanumberic NOTSpaces)

Hello,

I am trying to remove all non alphanumeric characters, but not spaces.

This is the test script I am running, but if the keyword is “Test It”, it echos “TestIt”.

[code=php]$keyword = $_GET[‘keyword’];

$var = $keyword;
$stripped = ereg_replace(“[^+A-Za-z0-9]”, “”, $var);

echo $stripped;[/code]

Any help is appreciated. ?!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@h3r0authorAug 08.2007 — I got it to work with:
[code=php]$var = $keyword;
$str = str_replace(" ", "+", $var);
$stripped = ereg_replace("[^A-Za-z0-9+]", "", $str);

$str1 = str_replace("+", " ", $stripped);[/code]


I'll clean up the code, but that's what I got in case people are wondering.
Copy linkTweet thisAlerts:
@mojtabaAug 08.2007 — Hello Dear,

please use this code (with space):

[code=php]$keyword = $_GET['keyword'];

$var = $keyword;
$stripped = ereg_replace("[^A-Za-z0-9 ]", "", $var);


echo $stripped;
[/code]


Bye.
×

Success!

Help @h3r0 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...