explode() is not strpos() - [empty() is not broken]
Let's say that I worked on a recipe website.
I coded something like this:
PS: I was using Drupal, that is where theme() and t() comes from.
The problem was that no matter what, the block would always show up, with one item that shows nothing.
<h3>List of ingredients</h3>
I spent 30 minutes trying to debug this code. Trying to figure out why it was printing my list when it should not when the list is empty.
It turned out that I misunderstood what explode() was returning.
I presumed that if no comas were found, it would return an empty array.
$ingredients = array('');
The documentation clearly says:
Since my string was an empty string, that is exacly what got returned.
I fixed my code by doing:
Make a Payment to Christian Roy