Maverickb7 Posted October 10, 2006 Share Posted October 10, 2006 How can I skip the first two items in an array. I'm trying to display a bunch of images within a directory by grabbing all the file names with php. Before the image files it shows . and .. so i'm wondering how I can remove them. Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/ Share on other sites More sharing options...
.josh Posted October 10, 2006 Share Posted October 10, 2006 array_shift() Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-106570 Share on other sites More sharing options...
Maverickb7 Posted October 10, 2006 Author Share Posted October 10, 2006 how would I use that to skip the first two items in an array? I tried to look it up on the net through google but it didn't really bring up any results that explained what I wanted. Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-106575 Share on other sites More sharing options...
.josh Posted October 10, 2006 Share Posted October 10, 2006 array_shift($yourarray);how about trying [url=http://www.php.net/array_shift]the manual[/url] instead. Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-106576 Share on other sites More sharing options...
brendandonhue Posted October 10, 2006 Share Posted October 10, 2006 You can use glob() to just get the names of the files you want, and not have . and .. in your array in the first place. Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-106580 Share on other sites More sharing options...
Maverickb7 Posted October 10, 2006 Author Share Posted October 10, 2006 examples? Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-106581 Share on other sites More sharing options...
AndyB Posted October 10, 2006 Share Posted October 10, 2006 http://ca.php.net/manual/en/function.glob.phpYou can check the user notes for examples. Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-106585 Share on other sites More sharing options...
Maverickb7 Posted October 11, 2006 Author Share Posted October 11, 2006 ok i'm useless.. can someone give me an example of how to do this.. i still can't figure it out by reading those pages. Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-107248 Share on other sites More sharing options...
brendandonhue Posted October 12, 2006 Share Posted October 12, 2006 What files are you trying to list? *.gif, *.jpg, etc? Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-108048 Share on other sites More sharing options...
Maverickb7 Posted October 12, 2006 Author Share Posted October 12, 2006 yes. I'm trying to display image files. Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-108118 Share on other sites More sharing options...
Barand Posted October 12, 2006 Share Posted October 12, 2006 Don't put the . and .. in the array to start with.And if you want an example,http://www.php.net/readdir Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-108122 Share on other sites More sharing options...
brendandonhue Posted October 13, 2006 Share Posted October 13, 2006 [quote author=Maverickb7 link=topic=111014.msg451166#msg451166 date=1160691714]yes. I'm trying to display image files.[/quote]$images = glob("/images/{*.jpg,*.gif, *.png}", GLOB_BRACE); Link to comment https://forums.phpfreaks.com/topic/23486-skip-first-two-items-in-array/#findComment-108663 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.