<?php
/* create directory iterator based on current directory */
$dir = new DirectoryIterator(dirname(__FILE__));
while (
$dir->valid()) { // while there are valid entries
    
if ($dir->isFile()) { // check if we are dealing with a file
        /* print file name & it's size */
        
echo "Name: ".$dir->getFilename().", size: ".$dir->getSize()."<br />";
    }
    
$dir->next(); // move to next entry
}
?>
Output
Name: static.jpg, size: 21020
Name: obj_autoload.php, size: 348
Name: standard2.xml, size: 613
Name: revolution.xml, size: 367
Name: streams_ex1.xml, size: 206
Name: obj_con_des5.php, size: 138
Name: obj_method_over.xml, size: 214
Name: che.gif, size: 19361
Name: soap_server.php, size: 287
Name: titlepage.xml, size: 77
Name: obj_tostring.php, size: 186
Name: spl_ex1.xml, size: 109
Name: obj_ppp.xml, size: 256
Name: recycle.gif, size: 2755
Name: tidy.php, size: 232
Name: sqlite_ex2.xml, size: 121
Name: streams2.php, size: 451
Name: standard.xml, size: 606
Name: xsl.xml, size: 518
Name: tidy2.php, size: 233
Name: obj_exceptions.xml, size: 327
Name: obj_tostring.xml, size: 229
Name: xml_intro.xml, size: 587
Name: obj_indirect.xml, size: 294
Name: thankyou.xml, size: 596
Name: obj_interface.php, size: 490
Name: tidy_ex1.xml, size: 106
Name: abstract.jpg, size: 40946
Name: evolution.jpg, size: 12405
Name: obj_indirect.php, size: 365
Name: under-construction.jpg, size: 21752
Name: tidy.jpg, size: 28355
Name: obj_method_over.php, size: 323
Name: spl_intro.xml, size: 360
Name: sqlite_oo.php, size: 466
Name: obj_dom.php, size: 499
Name: tidy_intro.xml, size: 602
Name: magician.gif, size: 4506
Name: soap.xml, size: 667
Name: obj_final.php, size: 286
Name: obj_con.php, size: 255
Name: obj_static.xml, size: 281
Name: obj_con_des4.php, size: 76
Name: obj_final.xml, size: 240
Name: obj_get_set.xml, size: 283
Name: stream.jpg, size: 45657
Name: streams.php, size: 285
Name: obj_autoload2.php, size: 35
Name: obj_exception.php, size: 477
Name: autoload.jpg, size: 132572
Name: obj_ppp2.xml, size: 244
Name: xsl.php, size: 991
Name: obj_clone2.xml, size: 250
Name: obj_clone.xml, size: 241
Name: obj_interface.xml, size: 259
Name: obj_const.php, size: 106
Name: obj_con_des2.xml, size: 231
Name: xsl_ex.xml, size: 104
Name: dolly.jpg, size: 48404
Name: sqlite_intro.xml, size: 554
Name: sqlite_proc.php, size: 462
Name: sqlite.gif, size: 3062
Name: soap_ex.xml, size: 210
Name: soap_client.php, size: 173
Name: obj_const.xml, size: 243
Name: obj_abstract.php, size: 285
Name: obj_ref2.xml, size: 240
Name: obj_static.php, size: 156
Name: obj_clone2.php, size: 253
Name: obj_ref2.php, size: 279
Name: obj_ppp2.php, size: 366
Name: streams_ex2.xml, size: 109
Name: obj_clone.php, size: 204
Name: obj_abstract.xml, size: 385
Name: obj_ref.xml, size: 277
Name: ivorysoap.gif, size: 8614
Name: obj_simplexml.php, size: 440
Name: obj_ppp.php, size: 638
Name: obj_get_set.php, size: 298
Name: dom_ex.xml, size: 108
Name: obj_ref.php, size: 283
Name: tidy_ex2.xml, size: 184
Name: different.jpg, size: 14503
Name: sqlite_ex.xml, size: 111
Name: evolution.xml, size: 397
Name: obj_con_des.xml, size: 497
Name: simplexml.xml, size: 271
Name: spl_ex1.php, size: 386
Name: dom.xml, size: 493
Name: streams_intro.xml, size: 495
Name: obj_autoload.xml, size: 410