The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
ereg_replace question
I'm in need of some quick ereg_replace help. I'm trying to strip specific characters from a string, namely an asterisk and the whitespace immediately following/preceding it.
Typical string: * Forum * I want: Forum This is what I've got thus far: Code:
$forum[title_clean] = ereg_replace("[^A-Za-z0-9]", "", $forum[title_clean]); |
#2
|
||||
|
||||
Use preg and not ereg, preg is much faster.
PHP Code:
|
#3
|
||||
|
||||
Thanks for the assist, but now it seems that it killed the script, lol. It should be displaying all forums - but it's only displaying one; although that one forum does have its asterisks stripped.
|
#4
|
||||
|
||||
What's contained in the string '$forum[title_clean]'?
|
#5
|
||||
|
||||
The cleaned (done by vB default) title of each forum that's being output in the archive.
|
#6
|
|||
|
|||
Try trim to avoid making a regexp for '** * for*um* ** *' type things.
Code:
$forum['title_clean'] = trim($forum['title_clean'], '* '); |
#7
|
||||
|
||||
Ah, that worked perfect Calorie - thanks! They're called asterisks by the way.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|