php in_array search for php array value isn't functioning
<p>For some strange reason on </p>

<pre><code>if(in_array("January", $season)){
</code></pre>

<p>when I specify "January" in in_array it matches the array value. But when I use <code>$search_string</code> which contains the word January it doesn't match. Any reason why this happens? I removed space before and after the word and it still doesn't match. </p>

<pre><code>$season = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

print_r($lines);
Array ( [0] =&gt; January - March, November
[1] =&gt; 2 travelers:  Adult: $9,499 Child: $7,125
[2] =&gt; 4 travelers:  Adult: $8,315 Child: $6,235
[3] =&gt; 6 travelers:  Adult: $7,975 Child: $5,980
[4] =&gt; June - October, December
[5] =&gt; 2 travelers:  Adult: $10,799 Child: $8,099
[6] =&gt; 4 travelers:  Adult: $9,835 Child: $7,375
[7] =&gt; 6 travelers:  Adult: $9,535 Child: $7,150
)

var_dump($lines);
array(8) { [0]=&gt; string(47) "January - March, November
" [1]=&gt; string(48) "2 travelers:  Adult: $9,499 Child: $7,125
" [2]=&gt; string(49) "4 travelers:  Adult: $8,315 Child: $6,235
" [3]=&gt; string(47) "6 travelers:  Adult: $7,975 Child: $5,980
" [4]=&gt; string(46) "June - October, December
" [5]=&gt; string(49) "2 travelers:  Adult: $10,799 Child: $8,099
" [6]=&gt; string(49) "4 travelers:  Adult: $9,835 Child: $7,375
" [7]=&gt; string(47) "6 travelers:  Adult: $9,535 Child: $7,150
"
}

     foreach($lines as $key =&gt; $value){
         $search_string = explode("-", $value);
         $search_string = $search_string[0];
         echo "--"; echo $search_string = trim($search_string); echo "--"; //  --January-- 

         if(in_array("January", $season)){
             echo "Match found";
         } else {
             echo "Match not found";
         }
     }
</code></pre>

<p>Here is what I got so far: 
<a href="https://i.stack.imgur.com/GKgrZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GKgrZ.png" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/KEbqB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KEbqB.png" alt="enter image description here"></a></p>

<p>@spirit, here is where the array line is being created </p>

<pre><code>     $lines = array();
     foreach(preg_split("/((\r?\n)|(\r\n?))/", $seasonal_price) as $line){
         // Only add to array for lines with content
         if(trim($line)!="") $lines[] = $line;
     }
</code></pre>

<p><strong>Here is my final code and the final output:</strong></p>

<pre><code>             //Seasonal price
             $seasonal_price = $row['post_content'];

             //Split individual lines into an array
             $lines = preg_split("/[\r\n]+/", strip_tags($seasonal_price), -1, PREG_SPLIT_NO_EMPTY);

             //Define seasons
             $season = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

             echo "&lt;br&gt;";
             foreach ($lines as $key =&gt; $value) {

                     $search_string = explode("-", $value);
                     $search_string = trim($search_string[0]);

                     if (in_array($search_string, $season)) {
                         echo '&lt;i class="fa fa-money"&gt;&lt;/i&gt;&amp;nbsp;&lt;span class="head" style="font-weight:bold;"&gt;';echo$value;echo'&lt;/span&gt;';
                     } else {
                         echo '&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;';echo$value;echo'&lt;/span&gt;';
                     }
                     echo "&lt;br&gt;";
            }

        ?&gt;
</code></pre>

<p>The portion of code reflects the result from the image below from Label <strong>January and June</strong></p>

<p><a href="https://i.stack.imgur.com/bxdT5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bxdT5.png" alt="enter image description here"></a></p>

<p>The issue was that I wasn't seeing the hidden <code>&lt;strong&gt;</code> tag because of my html container on the browser window. I wasn't seeing the  tag, it was being parsed as an html tag. </p>