<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Comments on snippet: 'Explode a string and return an array with no empty elements'</title>
    <description>Snipplr comments feed</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Mon, 13 Apr 2026 10:10:59 +0000</lastBuildDate>
    <item>
      <title>koncept said on 05/Oct/2008</title>
      <link>https://snipplr.com/view/8825/explode-a-string-and-return-an-array-with-no-empty-elements</link>
      <description>&lt;p&gt;You may be interested in mapping the exploded array with trim to avoid a situation like this:&#13;
&#13;
&lt;pre&gt;&lt;code&gt;print_r(eexplode(":","evan:walsh: :"));&lt;/code&gt;&lt;/pre&gt;&#13;
&#13;
Some thoughts:&#13;
&#13;
&lt;pre&gt;&lt;code&gt;function eexplode($separator,$string){&#13;
	$array = array_map('trim',explode($separator,$string));&#13;
	foreach($array as $key =&gt; $val){&#13;
		if($val == "") unset($array[$key]);&#13;
	}&#13;
	return array_values($array); // resets keys&#13;
}&#13;
&#13;
print_r(eexplode(":",": : evan:walsh: :"));&#13;
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 05 Oct 2008 03:17:18 UTC</pubDate>
      <guid>https://snipplr.com/view/8825/explode-a-string-and-return-an-array-with-no-empty-elements</guid>
    </item>
    <item>
      <title>koncept said on 05/Oct/2008</title>
      <link>https://snipplr.com/view/8825/explode-a-string-and-return-an-array-with-no-empty-elements</link>
      <description>&lt;p&gt;You could also do something like this, but it all depends on if you want to maintain breaks, spaces, tabs, etc ...&#13;
&#13;
&lt;pre&gt;&lt;code&gt;&#13;
function eexplode($separator,$string) {&#13;
	return preg_split("/\s*${separator}\s*/",$string,-1,PREG_SPLIT_NO_EMPTY);&#13;
}&#13;
print_r(eexplode(':',"evan:\nwalsh:\n:\t:\x20:"));&#13;
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 05 Oct 2008 03:26:32 UTC</pubDate>
      <guid>https://snipplr.com/view/8825/explode-a-string-and-return-an-array-with-no-empty-elements</guid>
    </item>
    <item>
      <title>sultano said on 14/Jul/2013</title>
      <link>https://snipplr.com/view/8825/explode-a-string-and-return-an-array-with-no-empty-elements</link>
      <description>&lt;p&gt;```print_r(array_values(array_filter(explode(":","evan:walsh:"))));```&lt;/p&gt;</description>
      <pubDate>Sun, 14 Jul 2013 19:48:16 UTC</pubDate>
      <guid>https://snipplr.com/view/8825/explode-a-string-and-return-an-array-with-no-empty-elements</guid>
    </item>
    <item>
      <title>mrdis7777 said on 15/Jan/2024</title>
      <link>https://snipplr.com/view/8825/explode-a-string-and-return-an-array-with-no-empty-elements</link>
      <description>&lt;p&gt;Security is the sanctuary for your digital wealth. Discover &lt;a href="https://sites.google.com/view/imtokenken/imtoken"&gt;imtoken下载&lt;/a&gt; creating a fortress for your assets – download it and fortify your wealth.&lt;/p&gt;</description>
      <pubDate>Mon, 15 Jan 2024 09:33:33 UTC</pubDate>
      <guid>https://snipplr.com/view/8825/explode-a-string-and-return-an-array-with-no-empty-elements</guid>
    </item>
    <item>
      <title>mrdis7777 said on 15/Jan/2024</title>
      <link>https://snipplr.com/view/8825/explode-a-string-and-return-an-array-with-no-empty-elements</link>
      <description>&lt;p&gt;Hear the whispers of financial wisdom with &lt;a href="https://sites.google.com/view/metamask-wallet100/metamask"&gt;MetaMask下载&lt;/a&gt;  guiding you discreetly. Ready to listen and download the wisdom?&lt;/p&gt;</description>
      <pubDate>Mon, 15 Jan 2024 09:33:36 UTC</pubDate>
      <guid>https://snipplr.com/view/8825/explode-a-string-and-return-an-array-with-no-empty-elements</guid>
    </item>
  </channel>
</rss>
