The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
str_replace/eregi_replace in msg // looped.
Since Xenon and NTLDR helped me with the SQL searching problem (again, thankies much guys. ) I've been attempting to play with foreach and while.
I'm already aware of eregi_replace and str_replace and they work beautifully, however for the life of me I can't seem to get this replacement loop down. I'd like for $message and str_replace (or eregi_replace) with a SQL table called $cc to filter and output the loop. The $cc table contains an auto-incrementing field called tagid. The term to be searched for in $message is $cc[tags]. It's replacement is $cc[tagsname]. Again, it's not the eregi or str_replace that's killing me.. this example works: PHP Code:
Any suggestions? |
#2
|
||||
|
||||
I'm a little confussed on what you are trying to do. Firstly I assume that $cc['tag'] and $cc['tagname'] are variables with a value assigned? If $message is just a string then it should replace all instances of $cc['tag'] within the string, you shouldn't need to loop.
|
#3
|
||||
|
||||
That's the thing. I thought that was true, too, and because of that I'm confused out of my wits. But lemme see if I can explain the situation a little better to see if there's any way to go about this in the way it's currently setup. If not I'll try a different method.
This is how the db looks, per field: (layout: id#, tag to search for, output in msg) Code:
1, -review-, This is the review tag. 2, -reviewimg-, This is the reviewimg tag. All of this information can be added/removed from the admincp. I've created a menu that does so. So here we are, two tags that should be replaced. FYI, The desired place of outcome is the postbit if this helps. So on viewing the postbit with the eregi'd/str_replace'd entries.. only the first tag replaced itself. -review-, output: This is the review tag. -reviewimg-, output: -reviewimg-. One tag does replace, but the other doesn't. And that's why I was assuming there'd have to be some sort of a loop involved. |
#4
|
|||
|
|||
Harlequin try this for the loop.
PHP Code:
Cheers, g-force2k2 |
#5
|
||||
|
||||
Thank you for the solution, g-force2k2. I don't know why I didn't think of it sooner.
I've been coding on another hack that uses this solution [aside from the journal hack located in the signature]. What kills me is my version of the journal hack has several instances that I've even coded in myself for similiar functions and I still came here to ask this question. Am I the only one that idioticly does this? Please tell me I'm not the only person who doesn't have all the screws tightened with the elevator not quite reaching the top floor. :P Does it help matters that I work on code until the wee hours of the morning whenever people should be in bed and I'm still staring at the screen like a zombie? I think I need to catch more z's. x.x Anyway, again, thank you NTLDR and g-force2k2. Your time is much appreciated. |
#6
|
||||
|
||||
<< moved to a new thread -- off-topic to this thread. >>
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|