php max() and min() on associative array


<pre><code>print_r($pages);
print max($pages);
print min($pages);
</code></pre>

<p>shows me</p>

<pre><code>Array ( [0] =&gt; 1 [1] =&gt; 2 [2] =&gt; 3 ) 1 2 
</code></pre>

<p>While I was expecting the last two numbers to be 3 and 1. How come?</p>

<p>EDIT: further info</p>

<pre><code>$pages = $v-&gt;plaintext;
var_dump($pages);
$exp = explode("|", $pages);
print_r($exp);
print max($exp);
</code></pre>

<p>gives</p>

<pre><code>string(324) " 1 | 2 | 3 " Array ( [0] =&gt; 1 [1] =&gt; 2 [2] =&gt; 3 ) 1 
</code></pre>

<p>Not sure what the "string(324) is? It's still outputting "1" as the max($exp) ...</p>

<p>EDIT: found solution, I was dealing with strings. This now works and prints out 3.</p>

<pre><code>$pages = $v-&gt;plaintext;                 
$exp = explode("|", $pages);
$exp = array_map("trim", $exp);
$exp = array_map("intval", $exp);
print max($exp);
</code></pre>
