<?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>brian dichiara &#187; Code</title>
	<atom:link href="http://blog.briandichiara.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.briandichiara.com</link>
	<description>designer. developer. friend.</description>
	<lastBuildDate>Wed, 28 Sep 2011 04:36:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Switching IDEs! CodeIgniter Users Should Too!</title>
		<link>http://blog.briandichiara.com/switching-ides-codeigniter-users-should-too/</link>
		<comments>http://blog.briandichiara.com/switching-ides-codeigniter-users-should-too/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 23:57:12 +0000</pubDate>
		<dc:creator>briandichiara</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.briandichiara.com/?p=160</guid>
		<description><![CDATA[I don&#8217;t know about you, but changing IDEs is a major thing for me. As my development skills have progressed over the years, I have been looking for more ways to take advantage of the development software I&#8217;ve been using. I am constantly wanting to improve my development experience and trying to find ways to [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know about you, but changing IDEs is a major thing for me. As my development skills have progressed over the years, I have been looking for <a href="/dreamweaver-extensions/">more ways</a> to take advantage of the development software I&#8217;ve been using. I am constantly wanting to improve my development experience and trying to find ways to speed up programming. Well, this past week, I basically did an assessment of Dreamweaver and here are my conclusions.<br />
<span id="more-160"></span></p>
<ul>
<li style="color:#1D9F47; font-weight:bold; list-style:none; background-image:none; padding-left:0; margin-left:0;">Dreamweaver Pros</li>
<li>I like the code colors. (or maybe I&#8217;m just used to them)</li>
<li>&#8220;Upload on Save&#8221; feature. &#8211; I used to not be able to live without this feature, but as I&#8217;ve progressed as developer, I&#8217;ve been using a local webserver for testing before uploading anything to server. It makes development and testing a WHOLE lot faster.</li>
<li>Great Find/Replace tool (with Regex)</li>
<li>Not-so-bad code completion (at least for PHP)</li>
<li>The interface is easily de-cluttered.</li>
<li>Mac and PC versions available</li>
</ul>
<ul>
<li style="color:#BF3317; font-weight:bold; list-style:none; background-image:none; padding-left:0; margin-left:0;">Dreamweaver Cons</li>
<li>It&#8217;s really a glorified Frontpage. The application was designed for programmers and Front-end designers with little programming experience (more-so for the latter)</li>
<li>Limited programming tools</li>
<li>Bloated &#8211; As with most Adobe products, you never want to set any of them to an &#8220;Open with [this] by default&#8221; setting unless you have a pretty awesome computer.</li>
<li>Poor FTP &#8211; With me it was always timing out.</li>
<li>Most of the built in features are for people that don&#8217;t know how to program or want a more &#8220;point-and-click&#8221; way of doing things.</li>
<li>EXPENSIVE!</li>
<li>They tend to add useless features that only junk up the application, like Code Navigator and Spry</li>
</ul>
<p>So I searched <a href="http://en.wikipedia.org/wiki/List_of_PHP_editors">far and wide</a> for as many IDEs I could find to install and test on my machine. Here are some of the ones I tried out:</p>
<ul>
<li>Aptana</li>
<li>PHPEclipse</li>
<li>PHPEdit</li>
<li>Zend Studio</li>
<li>Komodo IDE</li>
<li>RapidPHP 2010</li>
<li>e Text Editor</li>
</ul>
<p>Now there are <a href="http://www.php-editors.com/">several</a> <a href="http://free-php-editor.com/">websites</a> where you will find reviews of the software mentioned above, however that&#8217;s not really what I wanted to accomplish in this post. I really wanted to compare the previous tool I was using with a new one. I could go on and on all day about what features I believe an IDE should have as well as my likes and dislikes of all the software above, however one piece of software I was really impressed with is <a href="http://www.mpsoftware.dk/phpdesigner.php">phpDesigner</a> (version 7).</p>
<p>As of this past week, I have officially moved on from ten years of using Dreamweaver to this very fine piece of software. You may have heard of it or tried it yourself, although I can&#8217;t speak for past versions. Let me just start by pointing out my most absolute favorite feature of this software. It&#8217;s a feature that I&#8217;ve been looking for in pretty much every piece of software I tested, but couldn&#8217;t find done as well as phpDesigner. phpDesigner doesn&#8217;t have any special name for it, but it&#8217;s the Code Completion tool I have wanted for years.</p>
<p>Just to give you an idea as to how much work it took to get this working here are the steps I took when testing this software:</p>
<ol>
<li>Create a new project (I used a project I was currently working on that was using the <a href="http://codeigniter.com/">CodeIgniter</a> framework)</li>
<li>Open a file in the project</li>
<li>Code completion automatically works.</li>
</ol>
<p>That&#8217;s IT! And not only does it work for all the classes and methods built into CodeIgniter, but it also adds the classes I write into the code tips as well. You should check out <a href="http://www.mpsoftware.dk/phpdesigner_screencasts.php">some of the videos</a> on their website to see this in action. They even use CodeIgniter in their examples, however I believe this will work with any PHP framework out there. The best part of it all: it&#8217;s super fast! I did find one or two other pieces of software out there that did something similar, however I was typing much faster than the letters would spit out onto the document due to software constantly trying to parse my text to decide what code hint or suggestion to display.</p>
<p>Here are some other features I really like in phpDesigner that I didn&#8217;t have in Dreamweaver:</p>
<ul>
<li>Built In Inline Debugger (with no additional setup or local web server required)</li>
<li>CTRL+Click on a method or custom function takes you to the declaration of that method/function</li>
<li>Custom syntax highlighting colors &#8211; Although I REALLY liked most of the default PHP color settings.</li>
<li>Auto completion library (the CTRL+J function)</li>
<li>Inline TODO and BUG panel</li>
<li>Support for PHP 5.3 (and any future versions)</li>
</ul>
<p>Here are the features that (thankfully) carried over from Dreamweaver:</p>
<ul>
<li>Customizable shortcuts (although it will not allow me to use Space or Enter in shortcuts)</li>
<li>Tabs for open files (with the ability to reload open)</li>
<li>Regex Find/Replace tool with the ability to search within a set of folders inside your project</li>
<li>Tabs for open files (with the ability to reload open)</li>
<li>Code Snippets</li>
</ul>
<p>I hate to do this, but I must be objective. Here are my gripes:</p>
<ul>
<li>The software has built in FTP, but no simple way uploading one file to and FTP sites relative directory. This problem is somewhat manageable by creating your FTP accounts in the Tools > FTP menu and having the FTP/SFTP panel side by side with the Project panel, however I would really like to have a feature where I can click a file in the Project panel and then click Upload, and it uploads in the corresponding directory of the remote site. The tool I thought that did this required that I select the FTP account and the directory every time I wanted to upload a file.</li>
<li>I would like for it to support Space and Enter in the keyboard shortcut customizer.</li>
<li>You cannot CTRL+C / CTRL+V Copy/Paste in the Project panel. There are 2 ways around this, however one way has another gripe. You can right click a file, but then you are given a custom context menu (bleh) which you must then click Shell menu to see the Copy command. (follow the same process for paste). The 2nd way is by clicking the folder location of the open file in the Status Bar, and using Windows to copy/paste.</li>
<li>The Project panel goes nuts when your project is on Network or Mapped drive with constantly updating the file list. It inserts a new item at the top of every open folder reading<br />
&#8220;Loading folder content&#8221; which is constantly distracting as well as irritating when you&#8217;re trying to work with files in that panel. This is not a problem for me at home for I&#8217;m working off a local drive, but at work it&#8217;s a bit frustrating.</li>
</ul>
<p>The software is still a bit larger than I&#8217;d like (not nearly as large as Dreamweaver), however I suppose that&#8217;s a sacrifice you must make if you want all the tools built into the software. If you&#8217;re looking for an extremely fast, lightweight application, I would highly recommend <a href="http://notepad-plus.sourceforge.net/">Notepad++</a>.</p>
<p>I think it&#8217;s a pretty safe to assumption to say there is no software out there that is perfect. Mainly because &#8220;perfect&#8221; is a personal opinion on how things should work. That is a struggle every programmer deals with trying to make software pleasing to every single user that uses it, it&#8217;s dang near impossible. But for all the amazing features I get with phpDesigner that I never had with Dreamweaver, I can live with this issues until they&#8217;re either addressed or I just get used to them and don&#8217;t even notice them anymore <img src='http://blog.briandichiara.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>I would like to encourage developers using CodeIgniter or any other PHP framework to <a href="http://www.mpsoftware.dk/downloads.php">try this out</a>. They offer a 21 day free trial as well as an extension of that trial if you need more time.</p>
<p>As an added bonus, I&#8217;m attaching my color styles for PHP, CSS, HTML, and JS. The javascript one hasn&#8217;t changed much from the defaults, except I colored the comments like Dreamweaver (in gray). Let me know if you try out this software, I&#8217;d love to hear your feedback!</p>
<ul>
<li><a href='http://blog.briandichiara.com/wp-content/uploads/2009/10/syntax_php2.dat'>syntax_php2</a></li>
<li><a href='http://blog.briandichiara.com/wp-content/uploads/2009/10/syntax_css2.dat'>syntax_css2</a></li>
<li><a href='http://blog.briandichiara.com/wp-content/uploads/2009/10/syntax_html2.dat'>syntax_html2</a></li>
<li><a href='http://blog.briandichiara.com/wp-content/uploads/2009/10/syntax_js2.dat'>syntax_js2</a></li>
</ul>
<p>For those who like a dark background, set your background to rgb(55,55,55), gutter to: rgb(37,37,37), active line to: rgb(37,37,37), and import these, originally from <a href="http://harrisbaird.co.uk/2009/06/29/railscasts-idlefingers-theme-for-phpdesigner.html">Harris Baird&#8217;s blog</a> known as Railscast/idlefingers:</p>
<ul>
<li><a href='http://blog.briandichiara.com/wp-content/uploads/2010/05/syntax_php2.dat'>syntax_php2</a></li>
<li><a href='http://blog.briandichiara.com/wp-content/uploads/2010/05/syntax_css2.dat'>syntax_css2</a></li>
<li><a href='http://blog.briandichiara.com/wp-content/uploads/2010/05/syntax_html2.dat'>syntax_html2</a></li>
<li><a href='http://blog.briandichiara.com/wp-content/uploads/2010/05/syntax_js2.dat'>syntax_js2</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.briandichiara.com/switching-ides-codeigniter-users-should-too/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP Function for URI and URI Segments</title>
		<link>http://blog.briandichiara.com/php-uri-function/</link>
		<comments>http://blog.briandichiara.com/php-uri-function/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 20:23:57 +0000</pubDate>
		<dc:creator>briandichiara</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.briandichiara.com/?p=152</guid>
		<description><![CDATA[Here's a function I wrote to parse through the URI to get segments. I wrote it to use with CodeIgniter to get URI segments before they had been altered and "-" gets changed to "_". It can be used in any application. PLAIN TEXT PHP: &#60;?php function uri&#40;$segment=NULL, $qs=false&#41;&#123; &#160; &#160; $uri = $_SERVER&#91;'REQUEST_URI'&#93;; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Here's a function I wrote to parse through the URI to get segments. I wrote it to use with CodeIgniter to get URI segments before they had been altered and "-" gets changed to "_". It can be used in any application.<br />
<span id="more-152"></span></p>
<div class="igBar"><span id="lphp-3"><a href="#" onclick="javascript:showPlainTxt('php-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-3">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> uri<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segment</span>=<span style="color:#000000; font-weight:bold;">NULL</span>, <span style="color:#0000FF;">$qs</span>=<span style="color:#000000; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$uri</span> = <span style="color:#0000FF;">$_SERVER</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'REQUEST_URI'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<span style="color:#0000FF;">$qs</span> || <span style="color:#0000FF;">$segment</span> !== <span style="color:#000000; font-weight:bold;">NULL</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/strpos"><span style="color:#000066;">strpos</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$uri</span>, <span style="color:#FF0000;">'?'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/list"><span style="color:#000066;">list</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$uri</span>, <span style="color:#0000FF;">$query</span><span style="color:#006600; font-weight:bold;">&#41;</span> = <a href="http://www.php.net/explode"><span style="color:#000066;">explode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'?'</span>, <span style="color:#0000FF;">$uri</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segment</span> !== <span style="color:#000000; font-weight:bold;">NULL</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/is_string"><span style="color:#000066;">is_string</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segment</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segment</span> != <span style="color:#FF0000;">'last'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span> <a href="http://www.php.net/strlen"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$uri</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt;= <a href="http://www.php.net/strlen"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segment</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <a href="http://www.php.net/substr"><span style="color:#000066;">substr</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$uri</span>, <span style="color:#CC66CC;color:#800000;">0</span>, <a href="http://www.php.net/strlen"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segment</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$str</span> = <a href="http://www.php.net/trim"><span style="color:#000066;">trim</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$uri</span>, <span style="color:#FF0000;">'/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$segments</span> = <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/strpos"><span style="color:#000066;">strpos</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$str</span>, <span style="color:#FF0000;">'/'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <a href="http://www.php.net/explode"><span style="color:#000066;">explode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'/'</span>, <span style="color:#0000FF;">$str</span><span style="color:#006600; font-weight:bold;">&#41;</span> : <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$str</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$ttl</span> = <a href="http://www.php.net/count"><span style="color:#000066;">count</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segments</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/is_string"><span style="color:#000066;">is_string</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segment</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#0000FF;">$segment</span> == <span style="color:#FF0000;">'last'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$seg</span> = <a href="http://www.php.net/array_pop"><span style="color:#000066;">array_pop</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segments</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">elseif</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segment</span> &lt;= <span style="color:#0000FF;">$ttl</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segment</span> &lt;<span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#0000FF;">$segment</span> = <span style="color:#0000FF;">$ttl</span> - <a href="http://www.php.net/abs"><span style="color:#000066;">abs</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$segment</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color:#CC66CC;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$seg</span> = <span style="color:#0000FF;">$segments</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$segment</span>-<span style="color:#CC66CC;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#FF0000;">''</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$seg</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$uri</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Usage:</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showPlainTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// uri:&nbsp; http://www.mysite.com/some-controller/some-method/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> uri<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// displays: /some-controller/some-method/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> uri<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC66CC;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// displays: some-method</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Pass true into 2nd paramater ($qs) to display Query String with URI</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// uri:&nbsp; http://www.mysite.com/some-controller/?foo=bar&amp;bar=foo</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> uri<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#000000; font-weight:bold;">NULL</span>, <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// displays: /some-controller/?foo=bar&amp;bar=foo </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.briandichiara.com/php-uri-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updated qrayg Menus</title>
		<link>http://blog.briandichiara.com/updated-qrayg/</link>
		<comments>http://blog.briandichiara.com/updated-qrayg/#comments</comments>
		<pubDate>Fri, 01 May 2009 03:30:55 +0000</pubDate>
		<dc:creator>briandichiara</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://blog.briandichiara.com/?p=64</guid>
		<description><![CDATA[A while back I found a modified version of the Suckerfish dropdown css menus from A List Apart that had the CSS written out for 4 submenus. For the longest time I continued to return to the site (formerly Solar Dream Studios) to download a fresh version of the menus and javascript. Well, it appears [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I found a modified version of the <a href="http://www.alistapart.com/articles/dropdowns" target="_blank">Suckerfish</a> dropdown css menus from <a href="http://www.alistapart.com/" target="_blank">A List Apart</a> that had the CSS written out for 4 submenus. For the longest time I continued to return to the site (formerly Solar Dream Studios) to download a fresh version of the menus and javascript. Well, it appears that as of April 15, the author <a href="http://qrayg.com/" target="_blank">Craig Erskine</a> has 'completely overhauled' the CSS. The stylesheet looks to be about half the size and is much easier to manage than before.</p>
<p><a href="http://qrayg.com/learn/code/cssmenus/" target="_blank">Check out the update here!</a><br />
<span id="more-64"></span><br />
I've got to hand it to him, I have returned to his site over and over because, in my opinion, this is the only way to go when it comes to drop down menus. They are search engine friendly, require only a tiny bit of javascript (just to support faithful ol' IE6), and fail quite nicely. He is also clear to mention that they only work with a valid DOCTYPE, which to me is important because it encourages those looking for a "quick menu script" to learn about validation and standards.</p>
<p>One day I hope to write a fancy menu creator which will be based off his primary css but allow you to easily customize the colors and styles in the menu with a color picker. Maybe even come up with some pretty simple themes for them. Maybe when I get some time, I'll actually get to do all the things I say I plan on doing one day <img src='http://blog.briandichiara.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Who else is using this menu?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.briandichiara.com/updated-qrayg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Custom Sort</title>
		<link>http://blog.briandichiara.com/mysql-custom-sort/</link>
		<comments>http://blog.briandichiara.com/mysql-custom-sort/#comments</comments>
		<pubDate>Thu, 01 Feb 2007 14:48:59 +0000</pubDate>
		<dc:creator>briandichiara</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://blog.briandichiara.com/mysql-custom-sort/</guid>
		<description><![CDATA[Here's something neat. If you want your SQL results in an order that's not alphabetical or numerical, this little bit of code will allow you to specify what order you want your fields to appear. PLAIN TEXT MySQL: ORDER BY CASE &#160; &#160; WHEN `col` = 'item' THEN 1 &#160; &#160; WHEN `col` = 'thing' [...]]]></description>
			<content:encoded><![CDATA[<p>Here's something neat. If you want your SQL results in an order that's not alphabetical or numerical, this little bit of code will allow you to specify what order you want your fields to appear.<span id="more-7"></span></p>
<div class="igBar"><span id="lmysql-6"><a href="#" onclick="javascript:showPlainTxt('mysql-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">MySQL:</span>
<div id="mysql-6">
<div class="mysql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #993333; font-weight: bold;">CASE</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHEN</span> `col` = <span style="color: #ff0000;">'item'</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHEN</span> `col` = <span style="color: #ff0000;">'thing'</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #cc66cc;color:#800000;">2</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHEN</span> `col` = <span style="color: #ff0000;">'stuff'</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #cc66cc;color:#800000;">3</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">WHEN</span> `col` = <span style="color: #ff0000;">'boom'</span> <span style="color: #993333; font-weight: bold;">THEN</span> <span style="color: #cc66cc;color:#800000;">4</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333; font-weight: bold;">ELSE</span> <span style="color: #cc66cc;color:#800000;">5</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">END</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Note that these are not in alphabetical order. You can still add other sort fields before and after this case. Pretty neat!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.briandichiara.com/mysql-custom-sort/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

