Note that there are some explanatory texts on larger screens.

plurals
  1. POArrays values not identical (but they are?)
    text
    copied!<p>I have two arrays. They seem to contain at least one identical set of values, but performing <code>array_diff()</code> does not return anything even though I think it should! This should have been just routine code but for some reason it's not liking what I've done.</p> <p>The weird thing is that <code>var_dump($queue[0]);</code> returns <code>String(167);</code> and <code>var_dump($videos[0])</code> returns <code>String(168)</code>.</p> <p>So clearly, they must be different right?</p> <p><code>echo similar_text($queue[0]), $videos[0]);</code> returns <code>167</code>. What!?</p> <p><strong>Note: These are just file names and do not represent the contents of the file.</strong></p> <p><strong>Videos Array</strong></p> <p><code>Array ( [0] =&gt; /var/www/downloads/j2/Dexter Season 1, 2, 3, 4, 5 &amp; 6 + Extras (Early Cuts, Audiobooks etc) DVDRip HDTV TSV/Season 3/Dexter Season 3 Episode 04 - All in the Family.avi )</code></p> <p><strong>Queue Array</strong></p> <p><code>Array ( [0] =&gt; /var/www/downloads/j2/Dexter Season 1, 2, 3, 4, 5 &amp; 6 + Extras (Early Cuts, Audiobooks etc) DVDRip HDTV TSV/Season 3/Dexter Season 3 Episode 04 - All in the Family.avi [1] =&gt; j2 )</code></p> <p><strong>Outputs</strong></p> <p><code>$diff = array_intersect($queue,$videos); print_r($diff);</code> <em>returns</em> <code>Array ( )</code></p> <p><code>var_dump($queue[0]);</code> returns <code>string(167) "/var/www/downloads/j2/Dexter Season 1, 2, 3, 4, 5 &amp; 6 + Extras (Early Cuts, Audiobooks etc) DVDRip HDTV TSV/Season 3/Dexter Season 3 Episode 04 - All in the Family.avi"</code></p> <p><code>var_dump($videos[0]);</code> <em>returns</em> <code>string(168) "/var/www/downloads/j2/Dexter Season 1, 2, 3, 4, 5 &amp; 6 + Extras (Early Cuts, Audiobooks etc) DVDRip HDTV TSV/Season 3/Dexter Season 3 Episode 04 - All in the Family.avi"</code></p> <p><code>echo similar_text($queue[0], $videos[0]);</code> <em>returns</em> <code>167</code>.</p> <p>I've put the strings into JavaScript character counts, I've used strlen(), trim() to trim whitespace, I've even manually counted each character individually. What's going on?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload