Log in

View Full Version : [variable] within a bbcode


Equinox68
01-19-2007, 04:30 PM
I am trying to use a random number variable within a custom bbcode.

basically I have a tag called [rand] that produces random numbers from 1 - 15

The php code looks like this

<phpcode><![CDATA[$this->post['message'] = preg_replace('/\[rand\]/i',mt_rand(1,15),$this->post['message']);]]></phpcode>

I also have a custom bbcode called where you can input any text you want and it shows a smilie holding a sign with whatever you wrote.

All my smilies for this bbcode are named the same with numbers at the end such as sign1.png, sign2.png, sign3.png, etc etc

What I want to do is make the smilies change by randomly calling up a different number.

This is what I'm currently running for the sign.

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" style="background-color: White; border: 1px solid Black; padding: 1px;"><FONT COLOR="Black"><normalfont>{param}</normalfont></FONT>
</td>
</tr>
<tr>
<td align="center">
<img src="http://mywebsite/images/sign{option}.png" alt="" border="0">
</td>
</tr>
</table>

What I want is something like /images/sign[rand].png

This obviously doesn't work. I've tried having my custom bbcode look something like this

[sign=[rand]]blah blah and obviously this doesnt work.

Could someone tell me what I could do to accomplish this?

I'd appreciate any help on this.

Someone must know this

Someone must know

Anyone?