<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: empty code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 01:39:54 GMT</pubDate>
    <description>DZone Snippets: empty code</description>
    <item>
      <title>Value coalescence in PHP</title>
      <link>http://snippets.dzone.com/posts/show/3664</link>
      <description>Here's something I keep on having to do in PHP and other languages. Often I need to find the first non-empty value from a set of arguments. Here's how I do it.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function coalesce() {&lt;br /&gt;    $args = func_get_args();&lt;br /&gt;    foreach ($args as $arg) {&lt;br /&gt;        if (!empty($arg)) {&lt;br /&gt;            return $arg;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    return $args[0];&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The function assumes that it will be called with at least one value. It can be trivially altered to use is_null() instead if that suits.</description>
      <pubDate>Tue, 13 Mar 2007 11:00:32 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3664</guid>
      <author>keith (Keith Gaughan)</author>
    </item>
    <item>
      <title>Delete empty directories (UNIX)</title>
      <link>http://snippets.dzone.com/posts/show/3012</link>
      <description>// Shell command to delete empty directories. May have to run several times to get everything.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;find . -type d -empty | xargs rmdir -&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 18 Nov 2006 03:21:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3012</guid>
      <author>jasonbentley (Jason Bentley)</author>
    </item>
  </channel>
</rss>
