|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
limited list from txt
hi,
I am just a beginner in PHP. I am using the script from one of the tutorials to get my news-items from a text file. ================== <?PHP $data = file('news.txt'); $data = array_reverse($data); foreach($data as $element) { $element = trim($element); $pieces = explode("|", $element); echo $pieces[0] . ": " . $pieces[1] . "<BR>"; } ?> ================== How can I limit the list to the last 5 items??? Paul |
|
#2
|
|||
|
|||
|
RE: limited list from txt
|
|
#3
|
|||
|
|||
|
RE: limited list from txt
well ya learn something new every day
|
|
#4
|
|||
|
|||
|
RE: limited list from txt
|
|
#5
|
|||
|
|||
|
RE: limited list from txt
or simply use array_slice() - that's what it is there for ;)
if u want to understand this better, go to http://php.net/array_slice |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > limited list from txt |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|