Crisp 01-07-2010, 09:09 PM Ok, I need your help with something.
I want to have something like this:
$test = "<if>Hello world</if>";
//Now, I want to replace anything after the <if> tag with nothing. But I want it to end and execute the rest of the code once </if> is there
//How can I do this?
Basically that's it.
I'm not 100% how I would do this.
Could you help me out what I can do?
Thanks a lot. :)
Crisp 01-07-2010, 11:36 PM Would you use Regex or something?
(Sorry, couldn't edit post)
masterofollies 01-08-2010, 01:14 AM IF, ELSEIF, ELSE is setup like this
if ($blue == $color) {
echo 'Yes blue is a color.';
}
elseif ($blue == $animal) {
echo 'Blue is not an animal';
}
else {
echo 'Blue is neither a color or animal';
}
JAY6390 01-08-2010, 01:24 AM $test = "<if>Hello world</if>";
$test = preg_replace('%(<if>).*?(</if>)%i', '$1$2', $test);Something like that?
Not quite sure what you meant to be honest, especially the execution thing
masterofollies 01-08-2010, 02:33 PM There is no tag called <if>
angst 01-08-2010, 02:40 PM IF, ELSEIF, ELSE is setup like this
if ($blue = $color) {
echo 'Yes blue is a color.';
}
elseif ($blue = $animal) {
echo 'Blue is not an animal';
}
else {
echo 'Blue is neither a color or animal';
}
this would always be true,
you need to have double equals; if($Value == $Something)
Len Whistler 01-08-2010, 11:28 PM I'm confused with the original post, as masterofollies pointed out if already has a purpose. if is a reserved word in php and it's not a good idea to use it in other ways.
http://www.php.net/manual/en/reserved.keywords.php
Perhaps you could explain what <if> </if> is for.
---------------
Crisp 01-09-2010, 03:01 AM Of course I know <if> isn't a tag. :p
I was going to have <if> in a template for easy use.
Anyways, I'm not sure I'm going to use it anymore, but thanks anyways guys. :)
masterofollies 01-09-2010, 03:34 AM this would always be true,
you need to have double equals; if($Value == $Something)
Crap haha I don't know where my head is today. Variable signing is single, comparing to is double. Blah! :thumbsup:
masterofollies 01-09-2010, 03:36 AM Of course I know <if> isn't a tag. :p
I was going to have <if> in a template for easy use.
Anyways, I'm not sure I'm going to use it anymore, but thanks anyways guys. :)
What your talking about is searching for a unique thing in a file, so you can upgrade the file remotely and it auto install into the script.
SMF forums does this very thing. You want to install a mod? run it and it updates all the scripts and your done. Am I correct on what you are talking about?
Crisp 01-09-2010, 03:52 AM Actually I'm creating my own forum software. :)
That's why I have a few threads here asking for a few things.
Trying to get the best and easiest way to use, and code.
i would suggest reading some php.net stuff.
Rebbu 01-09-2010, 04:18 AM When I read this post the other day, I assumed you wanted to search for the contents of the <if> tag, and execute the contents of the tag (using some custom functions/scripts/wrapper), and delete the if tag and contents for echoing to the screen. Or something similar...
Anyway, I use a similar method for the CMS I'm developing, allowing users the ability to use some custom PHP functions and such.
|
|