<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Application Developer &#187; parse</title>
	<atom:link href="http://applicationdeveloper.net/tag/parse/feed/" rel="self" type="application/rss+xml" />
	<link>http://applicationdeveloper.net</link>
	<description>Making money online</description>
	<lastBuildDate>Sat, 26 Sep 2009 20:31:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Parse a String with BB Code or RSS using PHP</title>
		<link></link>
		<comments>http://applicationdeveloper.net/2009/07/15/parse-string-bb-code-rss/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 12:01:05 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[bb code]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[forums]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string handling]]></category>

		<guid isPermaLink="false">http://applicationdeveloper.net/?p=60</guid>
		<description><![CDATA[Writing a function to parse BB Code and RSS Feeds each time you need them is a pain. Here&#8217;s a use function to throw into an include or just have on hand for later.A little while ago I was stuck reading forum content outside of the forums. Pulling anything from the database is easy but [...]]]></description>
			<content:encoded><![CDATA[Writing a function to parse BB Code and RSS Feeds each time you need them is a pain. Here&#8217;s a use function to throw into an include or just have on hand for later.<br /><br />A little while ago I was stuck reading forum content outside of the forums. Pulling anything from the database is easy but without a nice set of functions to handle the odd strings that can somehow come out, it can be a little difficult. This function here made everything a lot better. Unless your forums look like this:<p style="text-align: center;"><img class="size-full wp-image-62 aligncenter" title="forums" src="http://applicationdeveloper.net/wp-content/uploads/2009/07/forums.gif" alt="forums" width="400" height="271" /></p>
<br />This string handling function will do most of work for you once you set the tags. To improve on the function, just make parsed tags dynamic and pass them into the function when calling it.<br /><br /><pre class="devcodeblock" title="PHP"><table class="devcodetools"><tbody><tr><td>&nbsp;PHP&nbsp;|&nbsp;</td><td style="background-image:url('http://applicationdeveloper.net/wp-content/plugins/devformatter/img/devformatter-copy.png');background-repeat:no-repeat;background-position:50% 50%;width:16px;height:16px;"/><embed id="ZeroClipboard2" src="http://applicationdeveloper.net/wp-content/plugins/devformatter/_zclipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16px" height="16px" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&width=16&height=16" wmode="transparent" /></td><td>&nbsp;copy&nbsp;code&nbsp;|</td><td style="cursor:pointer" title="DevFormatter Plugin" onclick="devfmt_credits()">?</td><td width="99%">&nbsp;</td></tr></tbody></table><div class="devcodeoverflow"><table class="devcodearea" width="100%"><tr><td class="devcodelines" width="1%">01</td><td class="devcodelinesarea"><pre class="devcode devcodeline"></pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">02</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">// Setup functions</pre></td></tr><tr><td class="devcodelines" width="1%">03</td><td class="devcodelinesarea"><pre class="devcode devcodeline">function get_string_between($string, $start, $end){</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">04</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">        $string = &quot; &quot;.$string;</pre></td></tr><tr><td class="devcodelines" width="1%">05</td><td class="devcodelinesarea"><pre class="devcode devcodeline">        $ini = strpos($string,$start);</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">06</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">        if ($ini == 0) return &quot;&quot;;</pre></td></tr><tr><td class="devcodelines" width="1%">07</td><td class="devcodelinesarea"><pre class="devcode devcodeline">        $ini += strlen($start);   </pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">08</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">        $len = strpos($string,$end,$ini) - $ini;</pre></td></tr><tr><td class="devcodelines" width="1%">09</td><td class="devcodelinesarea"><pre class="devcode devcodeline">        return substr($string,$ini,$len);</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">10</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">}</pre></td></tr><tr><td class="devcodelines" width="1%">11</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">12</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">$fullstring = &quot;this is my [tag]app[/tag]&quot;;</pre></td></tr><tr><td class="devcodelines" width="1%">13</td><td class="devcodelinesarea"><pre class="devcode devcodeline">$parsed = get_string_between($fullstring, &quot;[tag]&quot;, &quot;[/tag]&quot;);</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">14</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines" width="1%">15</td><td class="devcodelinesarea"><pre class="devcode devcodeline">echo $parsed; // (result = app) </pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">16</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"></pre></td></tr></table></div></pre>]]></content:encoded>
			<wfw:commentRss>http://applicationdeveloper.net/2009/07/15/parse-string-bb-code-rss/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>String Handling: Parsing Links from a String</title>
		<link></link>
		<comments>http://applicationdeveloper.net/2009/07/10/string-handling-parsing-links-string/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 14:33:17 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string handling]]></category>

		<guid isPermaLink="false">http://applicationdeveloper.net/?p=6</guid>
		<description><![CDATA[With the popularity of APIs that connect to Twitter, Facebook, and even sites like StumbleUpon, it&#8217;s becoming increasing important to work with String Handling functions.Here&#8217;s a very handy function to replace a link in a String with the html format for posting on the web.I can&#8217;t remember where I got this from but someone deserves [...]]]></description>
			<content:encoded><![CDATA[With the popularity of APIs that connect to <a href="http://twitter.com">Twitter</a>, <a href="http://facebook.com">Facebook</a>, and even sites like <a href="http://stumbleupon.com">StumbleUpon</a>, it&#8217;s becoming increasing important to work with String Handling functions.<br /><br />Here&#8217;s a very handy function to replace a link in a String with the html format for posting on the web.<br /><br />I can&#8217;t remember where I got this from but someone deserves credit for helping write this:<br /><br /><pre class="devcodeblock" title="PHP"><table class="devcodetools"><tbody><tr><td>&nbsp;PHP&nbsp;|&nbsp;</td><td style="background-image:url('http://applicationdeveloper.net/wp-content/plugins/devformatter/img/devformatter-copy.png');background-repeat:no-repeat;background-position:50% 50%;width:16px;height:16px;"/><embed id="ZeroClipboard4" src="http://applicationdeveloper.net/wp-content/plugins/devformatter/_zclipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16px" height="16px" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&width=16&height=16" wmode="transparent" /></td><td>&nbsp;copy&nbsp;code&nbsp;|</td><td style="cursor:pointer" title="DevFormatter Plugin" onclick="devfmt_credits()">?</td><td width="99%">&nbsp;</td></tr></tbody></table><div class="devcodeoverflow"><table class="devcodearea" width="100%"><tr><td class="devcodelines" width="1%">01</td><td class="devcodelinesarea"><pre class="devcode devcodeline"> </pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">02</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">function clickable_link($text)</pre></td></tr><tr><td class="devcodelines" width="1%">03</td><td class="devcodelinesarea"><pre class="devcode devcodeline">{</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">04</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> $text = preg_replace('#(script|about|applet|activex|chrome):#is', &quot;:&quot;, $text);</pre></td></tr><tr><td class="devcodelines" width="1%">05</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">06</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> // pad it with a space so we can match things at the start of the 1st line.</pre></td></tr><tr><td class="devcodelines" width="1%">07</td><td class="devcodelinesarea"><pre class="devcode devcodeline"> $ret = ' ' . $text;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">08</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines" width="1%">09</td><td class="devcodelinesarea"><pre class="devcode devcodeline"> // matches an &quot;xxxx://yyyy&quot; URL at the start of a line, or after a space.</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">10</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> // xxxx can only be alpha characters.</pre></td></tr><tr><td class="devcodelines" width="1%">11</td><td class="devcodelinesarea"><pre class="devcode devcodeline"> // yyyy is anything up to the first space, newline, comma, double quote or &lt;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">12</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> $ret = preg_replace(&quot;#(^|[\n ])([\w]+?://[\w\#$%&amp;~/.\-;:=,?@\[\]+]*)#is&quot;, &quot;&lt;a href=&quot;\&quot; target=&quot;\&quot;_blank\&quot;&quot;&gt;&lt;/a&gt;&quot;, $ret);</pre></td></tr><tr><td class="devcodelines" width="1%">13</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">14</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> // matches a &quot;www|ftp.xxxx.yyyy[/zzzz]&quot; kinda lazy URL thing</pre></td></tr><tr><td class="devcodelines" width="1%">15</td><td class="devcodelinesarea"><pre class="devcode devcodeline"> // Must contain at least 2 dots. xxxx contains either alphanum, or &quot;-&quot;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">16</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> // zzzz is optional.. will contain everything up to the first space, newline,</pre></td></tr><tr><td class="devcodelines" width="1%">17</td><td class="devcodelinesarea"><pre class="devcode devcodeline"> // comma, double quote or &lt;.</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">18</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> $ret = preg_replace(&quot;#(^|[\n ])((www|ftp)\.[\w\#$%&amp;~/.\-;:=,?@\[\]+]*)#is&quot;, &quot;&lt;a href=&quot;\&quot; target=&quot;\&quot;_blank\&quot;&quot;&gt;&lt;/a&gt;&quot;, $ret);</pre></td></tr><tr><td class="devcodelines" width="1%">19</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">20</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> // matches an email@domain type address at the start of a line, or after a space.</pre></td></tr><tr><td class="devcodelines" width="1%">21</td><td class="devcodelinesarea"><pre class="devcode devcodeline"> // Note: Only the followed chars are valid; alphanums, &quot;-&quot;, &quot;_&quot; and or &quot;.&quot;.</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">22</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> $ret = preg_replace(&quot;#(^|[\n ])([a-z0-9&amp;\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i&quot;, &quot;&lt;a href=&quot;\&quot;&gt;@&lt;/a&gt;&quot;, $ret);</pre></td></tr><tr><td class="devcodelines" width="1%">23</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">24</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> // Remove our padding..</pre></td></tr><tr><td class="devcodelines" width="1%">25</td><td class="devcodelinesarea"><pre class="devcode devcodeline"> $ret = substr($ret, 1);</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">26</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> return $ret;</pre></td></tr><tr><td class="devcodelines" width="1%">27</td><td class="devcodelinesarea"><pre class="devcode devcodeline">}</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">28</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"></pre></td></tr></table></div></pre>]]></content:encoded>
			<wfw:commentRss>http://applicationdeveloper.net/2009/07/10/string-handling-parsing-links-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
