FAQ |
Kalender |
|
![]() |
#1 | |||
|
||||
Klarade millennium-buggen
|
Gör en replace och byt ut alla radbrytningar till mellanslag först och sen explodera den med mellanslag kanske?
|
|||
![]() |
![]() |
![]() |
#2 | ||
|
|||
Flitig postare
|
Skrev ihop något..
Scriptet kollar om söksträngen matchar för- och efternamn. Kod:
<?php $file = 'file.txt'; $search = 'Johanna'; /* --------------------- */ $fp = @fopen($file, 'r') or die('Filen kunde inte läsas in'); $contents = NULL; $result = array(); if(is_resource($fp)){ while( ! feof($fp)) { $contents .= fgets($fp); } $lines = explode("\n", $contents); for($i = 0; $i < count($lines); $i++){ $person = explode(' ', $lines[$i]); if((stripos($person[0], $search) !== FALSE) OR (stripos($person[1], $search) !== FALSE)){ echo $lines[$i] . '<br />' . PHP_EOL; } } } else { echo 'Något gick snett..'; } |
||
![]() |
![]() |
Svara |
Ämnesverktyg | |
Visningsalternativ | |
|
|