<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[PunBB Forums — Help with  preg_replace]]></title>
		<link>https://punbb.informer.com/forums/topic/7118/help-with-pregreplace/</link>
		<atom:link href="https://punbb.informer.com/forums/feed/rss/topic/7118/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Help with  preg_replace.]]></description>
		<lastBuildDate>Fri, 15 Apr 2005 00:06:17 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Help with  preg_replace]]></title>
			<link>https://punbb.informer.com/forums/post/40461/#p40461</link>
			<description><![CDATA[<p>thanks guys. I got it working.</p><p><a href="http://jobs.gotoguide.org/viewtopic.php?pid=3#p3">http://jobs.gotoguide.org/viewtopic.php?pid=3#p3</a></p>]]></description>
			<author><![CDATA[null@example.com (druvans)]]></author>
			<pubDate>Fri, 15 Apr 2005 00:06:17 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/40461/#p40461</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help with  preg_replace]]></title>
			<link>https://punbb.informer.com/forums/post/40459/#p40459</link>
			<description><![CDATA[<p>Forget my last post, this was nonsense.</p><p>I think, I found the missing point. In your last example, you had an &#039;e&#039; at the end of your regular expression (after the final #) which was missing in your first examply. I guess, this is doing the eval() job.</p>]]></description>
			<author><![CDATA[null@example.com (spider8)]]></author>
			<pubDate>Thu, 14 Apr 2005 23:32:58 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/40459/#p40459</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help with  preg_replace]]></title>
			<link>https://punbb.informer.com/forums/post/40458/#p40458</link>
			<description><![CDATA[<p>druvans,</p><p>I still don&#039;t know exactly, what your problem is.</p><p>You are right, despite the &#039; &#039; around your function, the content gets eval()ed.</p><p>Now let&#039;s try this</p><div class="codebox"><pre><code>$text=preg_replace(&#039;#\[x\](.*?)\[/x\]#e&#039;, &quot;imagize(&#039;$1&#039;)&quot;, $text);</code></pre></div><p>so that the $1 will be translated instead of taken literally.</p>]]></description>
			<author><![CDATA[null@example.com (spider8)]]></author>
			<pubDate>Thu, 14 Apr 2005 23:27:34 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/40458/#p40458</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help with  preg_replace]]></title>
			<link>https://punbb.informer.com/forums/post/40454/#p40454</link>
			<description><![CDATA[<p>Thanks. I havent thgt abt&nbsp; the filenames yet.</p><p>I am able to execute and see the values with this line<br /></p><div class="codebox"><pre><code>&lt;h5&gt;&lt;?php $text= &quot;[x]druvans@gmail.com[/x]&quot;; $text=preg_replace(&#039;#\[x\](.*?)\[/x\]#e&#039;,&#039;imagize(\&#039;$1\&#039;)&#039;,$text); echo $text;  ?&gt;&lt;/h5</code></pre></div><p>I still cldnt figure out, how to integrate it to bbcode</p>]]></description>
			<author><![CDATA[null@example.com (druvans)]]></author>
			<pubDate>Thu, 14 Apr 2005 23:14:38 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/40454/#p40454</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help with  preg_replace]]></title>
			<link>https://punbb.informer.com/forums/post/40451/#p40451</link>
			<description><![CDATA[<p>druvans,</p><p>you might try to change your code in something like:</p><div class="codebox"><pre><code>$text = preg_replace(&quot;#\[x\](.*?)\[/x\]#&quot;, imagize($1), $text);</code></pre></div><p>but I&#039;m not sure, whether it works out for you. I have never used a function inside a preg_replace(), so I really don&#039;t know about it. If this doesn&#039;t work you might choose an iterative approach replacing one email address after the other. A third variant would be to apply your differently modified $text to the eval() function.</p><p>There is at least one more source for trouble in your imagize() function, that I found at a first glance. You use only the first part of the email address to determine the filename, so if you have two people with info@domain1.com and info@domain2.com they both will show up with the info.png image which serves for domain2.com.</p>]]></description>
			<author><![CDATA[null@example.com (spider8)]]></author>
			<pubDate>Thu, 14 Apr 2005 22:50:26 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/40451/#p40451</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help with  preg_replace]]></title>
			<link>https://punbb.informer.com/forums/post/40428/#p40428</link>
			<description><![CDATA[<p>I am not sure what exactly you mean by that. </p><p>thanks</p>]]></description>
			<author><![CDATA[null@example.com (druvans)]]></author>
			<pubDate>Thu, 14 Apr 2005 19:02:22 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/40428/#p40428</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help with  preg_replace]]></title>
			<link>https://punbb.informer.com/forums/post/40426/#p40426</link>
			<description><![CDATA[<p>you can&#039;t embed an image in the html you need to put the function in another file and call it</p>]]></description>
			<author><![CDATA[null@example.com (Connorhd)]]></author>
			<pubDate>Thu, 14 Apr 2005 18:43:16 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/40426/#p40426</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help with  preg_replace]]></title>
			<link>https://punbb.informer.com/forums/post/40415/#p40415</link>
			<description><![CDATA[<p>able to get it work, trying to integrate to bbcode</p><div class="codebox"><pre><code>&lt;h5&gt;&lt;?php $text= &quot;[x]druvans@gmail.com[/x]&quot;; $text=preg_replace(&#039;#\[x\](.*?)\[/x\]#e&#039;,&#039;imagize(\&#039;$1\&#039;)&#039;,$text); echo $text;  ?&gt;&lt;/h5&gt;

&lt;?php

/***********************************************************************
Druvan (druvan@gmail.com)
Use it anyway you want it.
************************************************************************/
function imagize($email){

$fontsize=4;
// Create the image
$im = @imagecreatetruecolor( strlen($email)*8, 16 ) or die( &quot;Cannot Initialize new GD image stream&quot; );
//Create background color
$background = imagecolorallocate($im, 255,  255,255);
imagefilledrectangle( $im, 0,0,strlen($email)*8, 16, $background);

// Create foreground color
$foreground = imagecolorallocate($im, 125,  125,125);
// write the string at the top left
imagestring($im,$fontsize, 0, 0, $email, $foreground);


// Using imagepng() results in clearer text compared with imagejpeg()
$filename =substr($email, 0,strrpos($email, &#039;@&#039;)).&quot;.png&quot;;
imagepng($im,$filename);
return &quot;&lt;img src=&#039;&quot;.$filename.&quot;&#039; /&gt;&quot;;
}

?&gt;


?&gt;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (druvans)]]></author>
			<pubDate>Thu, 14 Apr 2005 17:01:53 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/40415/#p40415</guid>
		</item>
		<item>
			<title><![CDATA[Re: Help with  preg_replace]]></title>
			<link>https://punbb.informer.com/forums/post/40390/#p40390</link>
			<description><![CDATA[<p>well its because you have put imagize in &quot; &quot;</p>]]></description>
			<author><![CDATA[null@example.com (Connorhd)]]></author>
			<pubDate>Thu, 14 Apr 2005 06:20:56 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/40390/#p40390</guid>
		</item>
		<item>
			<title><![CDATA[Help with  preg_replace]]></title>
			<link>https://punbb.informer.com/forums/post/40385/#p40385</link>
			<description><![CDATA[<p>I am trying to add a new bbcode called [x]druvan@gmail.com[/x], what I want is, whatever value placed inside this code, should be turned into images, for example, email ids.</p><p>I created a function called imagize, which basically converts the given text into a png image file, then returns the file name. This part works OK.</p><p>Now, I added all this to parser.php file and&nbsp; &nbsp;</p><div class="codebox"><pre><code>$text = preg_replace(&quot;#\[x\](.*?)\[/x\]#&quot;, &quot;imagize(&#039;$1&#039;)&quot;, $text);</code></pre></div><p>==&gt;&nbsp; imagize(&#039;druvan@gmail.com&#039;)</p><p>I am not able to execute&nbsp; &#039;imagize&#039; function, can someone help me.</p><p>Result&nbsp; &lt;img src=imagize(&#039;$1&#039;) /&gt;</p>]]></description>
			<author><![CDATA[null@example.com (druvans)]]></author>
			<pubDate>Thu, 14 Apr 2005 05:02:32 +0000</pubDate>
			<guid>https://punbb.informer.com/forums/post/40385/#p40385</guid>
		</item>
	</channel>
</rss>
