sviesc Posted April 14, 2004 Report Share Posted April 14, 2004 kāds varētu palīdzēt noteikt bildes izmēru pixseļos (piem.: 65X65) pie reizes vel derētu izštukot tādu lietu kā nolasam no dir bildes un tad randomā pa vienai drukājam pārlūkā nu teiksim pie refreša bilde mainās Link to comment Share on other sites More sharing options...
Kaklz Posted April 14, 2004 Report Share Posted April 14, 2004 kāds varētu palīdzēt noteikt bildes izmēru pixseļos (piem.: 65X65) pie reizes vel derētu izštukot tādu lietu kā nolasam no dir bildes un tad randomā pa vienai drukājam pārlūkā nu teiksim pie refreša bilde mainās http://lv.php.net/function.getimagesize Link to comment Share on other sites More sharing options...
bubu Posted April 14, 2004 Report Share Posted April 14, 2004 un pie reizes: http://lv.php.net/mt_rand Link to comment Share on other sites More sharing options...
sviesc Posted April 15, 2004 Author Report Share Posted April 15, 2004 par to random man ir skripts <?php if ($handle = opendir('img')) { while (false !== ($file = readdir($handle))) { echo "<img src=\"img/$file\"><br>"; } closedir($handle); } ?> bet man nav ideju kā izveidot tā lai netiek piņemti tie punkti, kuri norāda direktoriju un kā šo te sriptu sajūgtu ar random f-ciju lai pārlūkā tiktu izdrukāts tikai viena bilde, bet ar random f-ciju :blink: Link to comment Share on other sites More sharing options...
Aleksejs Posted April 15, 2004 Report Share Posted April 15, 2004 <?php $faili = scandir('img'); do { $gadiijumskaitlis = rand(0, sizeof($faili)-1); } while (is_file($faili[$gadiijumskaitlis]) == false); echo '<img src="' . $faili[$gadiijumskaitlis] . '"> ?> Link to comment Share on other sites More sharing options...
Aleksejs Posted April 15, 2004 Report Share Posted April 15, 2004 pie tās is_file pārbaudes, jānorāda arī katalogs, kurā tas fails atrodas, 'img' Link to comment Share on other sites More sharing options...
sviesc Posted April 15, 2004 Author Report Share Posted April 15, 2004 hmm nu nesaprotu totaliy no efect pat ja pieliek ; (pie echo) kur bij tas dirname jāliek? Link to comment Share on other sites More sharing options...
Aleksejs Posted April 15, 2004 Report Share Posted April 15, 2004 (edited) <?php $dira = '/var/www/htdocs/sviesc/img'; $webdira = '/img/'; $faili = scandir($dira); do { $gadiijumskaitlis = rand(0, sizeof($faili)-1); } while (is_file($dira . '/' . $faili[$gadiijumskaitlis]) == false); echo '<img src="' . $webdira . $faili[$gadiijumskaitlis] . '">'; ?> Šitā... Edited April 15, 2004 by Aleksejs Link to comment Share on other sites More sharing options...
sviesc Posted April 15, 2004 Author Report Share Posted April 15, 2004 nu nezinu man ka neko nerāda ta nerāda norādu kādu diru gribu tikuntā no image a moš tur priekš php kas jauzstāda? Link to comment Share on other sites More sharing options...
Aleksejs Posted April 15, 2004 Report Share Posted April 15, 2004 Nu ieliec tajā ciklā kādu echo, lai pārliecinātos, ko tieši tas masīvs satur... Link to comment Share on other sites More sharing options...
sviesc Posted April 15, 2004 Author Report Share Posted April 15, 2004 (edited) es atradu šādu te koda gabaliņu & wis strādā bet paldies par padomu :blink: <? mt_srand((double)microtime()*1000000); $imgs = dir('img'); while ($file = $imgs->read()) { if (eregi("gif", $file) || eregi("jpg", $file)) { $imglist .= "$file "; } } closedir($imgs->handle); $imglist = explode(" ", $imglist); $a = sizeof($imglist)-2; $random = mt_rand(0, $a); $image = $imglist[$random]; $content = "<br><center><img src=\"img/$image\" border=\"0\"><br><br></center>"; echo $content; ?> Edited April 15, 2004 by sviesc Link to comment Share on other sites More sharing options...
Aleksejs Posted April 15, 2004 Report Share Posted April 15, 2004 Njā... tikko ieskatījos manuālī: scandir (PHP 5 CVS only) <_< Link to comment Share on other sites More sharing options...
Recommended Posts