Toon posts:

Random images (een vreemde foutmelding)

Pagina: 1
Acties:
  • 39 views sinds 30-01-2008

Verwijderd

Topicstarter
Onderstaand script werkt al wel helemaal, maar hij geeft nog een vreemde foutmelding, namelijk
Warning: Wrong datatype for second argument in call to in_array() in /usr/local/slash/apache/vhosts/blablabla/httpdocs/header_random2.php on line 41

Dat is deze regel: if (!in_array($randval,$images)) {


<?
$handle = opendir( "/usr/local/slash/apache/vhosts/blablabla/httpdocs/dynamic/header/images" );
$imgArray = array( );

while( $file = readdir( $handle ) ) {
if( $file != "." && $file != ".." ) {
array_push( $imgArray, $file );
}
}
closedir( $handle );

mt_srand( (double)microtime( ) * 1000000 );

echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";

$theList = array();
while($tmpFile = readdir($handle))
if($tmpFile != '.' && $tmpFile != '..')
$theList[] = $tmpFile;

srand ((float) microtime() * 10000000);
$theRandomList = array_flip($theList);
foreach($theList as $theImage)
; // do something with '$theImage'

$x = 0;
while ($x <= 7) {

$randval = mt_rand( 0, sizeof( $imgArray ) - 1 );

if (!in_array($randval,$images)) {
if (substr($imgArray[$randval],-4) == ".jpg") {
print( "<td>[img]\"images/"[/img]</td>" );
$images[] = $randval;
$x = $x + 1;
}
}

}

echo "</tr></table>";
?>

  • ACM
  • Registratie: Januari 2000
  • Niet online

ACM

Software Architect

Werkt hier

Ben je er weer?

Van het simpelweg debuggen van je script zijn we hier nou eenmaal niet gediend.

Check je mail.

Dit topic is gesloten.