tags:

views:

91

answers:

1
print_r($pages);
print max($pages);
print min($pages);

shows me

Array ( [0] => 1 [1] => 2 [2] => 3 ) 1 2 

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

EDIT: further info

$pages = $v->plaintext;
var_dump($pages);
$exp = explode("|", $pages);
print_r($exp);
print max($exp);

gives

string(324) " 1 | 2 | 3 " Array ( [0] => 1 [1] => 2 [2] => 3 ) 1 

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

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

$pages = $v->plaintext;                 
$exp = explode("|", $pages);
$exp = array_map("trim", $exp);
$exp = array_map("intval", $exp);
print max($exp);
+1  A: 

The following works for me.

$a=array(1,2,3);

print_r($a);
print max($a);
print min($a);

You'll need to dump more debug info for your $pages var to dig more.

zaf
Thanks, var_dump of $pages led to me to the solution.
stef