Quote from: e-stonia at Nov 08, 2008, 11:46 AM
Sorry, I changed the the snippet call to uncached and I’m getting random number now but it’s not working still. The problem is probably in the line:
Because the echo $page gives me just the number not id=number.
No question about it --PHP’s dynamic variable typing strikes again. PHP sees the + sign and the fact that $page_id is a number and does its best to give you what it thinks you want -- a number. "id=" evaluates to zero and it adds the $page_id value.
You want:
$page = "id=" . $page_id;
or
$page = "id=";
$page .= $page_id;
And GaneshXL is right, array_rand() returns the *key* of the random element (my bad), so if you use his code to set $page_id, call the snippet uncached, and change the + sign, you should be in business with your original snippet.