Jump to content

[SOLVED] Correct way to define this variable?


ripkjs

Recommended Posts

are you assigning the results of preg_replace to anything?  It's not the same as preg_match where the results are put in the var specified in the argument.  You have to assign the results to a var with normal assignment:

 

// assuming you want to overwrite the same var...

$getPoints = preg_replace("/CLp/", $clP, $getPoints);

$clP = '<img src="imagelink.png" />';
preg_replace("/CLp/", $clP, $getPoints);

 

The reason it is not working, is because your preg_replace can not find "CLp" in the string in your variable.

 

no...the 2nd argument for preg_replace is what you want to replace the pattern matched in the 3rd argument with.

$clP = '<img src="imagelink.png" />';
preg_replace("/CLp/", $clP, $getPoints);

 

The reason it is not working, is because your preg_replace can not find "CLp" in the string in your variable.

 

no...the 2nd argument for preg_replace is what you want to replace the pattern matched in the 3rd argument with.

 

Yeah I realized that before your post, so I modified it!

I got it working, i think i was using double quotes:

$clP = "<img src="imagelink.png" />";

 

Brain fart... Works okay now with single quotes.  :-[

 

We won't tell anyone about this mmk!?

 

I don't see how that would work... I see an error...

 

using that would make "imagelink.png" no longer part of the string...

Most people like to shove their mistakes under the rug and try to erase the fact that it happened.

 

I wear my pin my stupid mistakes on my shirt for all to see, like a boyscout's sash full of badges.  See that way, I can prove I'm not talking out my ass when I say I know something.  I have the mistake to prove that I fucked up and learned, so you don't have to just take my word for it.

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.