Plik index.php zawiera string $output w którym są skrócone dane, które podmienia na właściwe za pomocą funkcji replace_more_news.
Funkcja replace_more_news podmienia dane wykonując jednocześnie funkcję odczytu danych z pliku files.txt (zawierających odpowiednie dane (inna funkcja zapisuje dane w tym pliku - nie dodawałem jej bo działa ok.)
Niestety porównanie danych z $file i $single_line_arr[0] - w if($file == $single_line_arr[0]) - zdaje sienei działać, mimo iż obie dane są identyczne.
Może mi ktoś pomóc ?
Poniżej zamieszczam listingi obu plików:
index.php
<? //////////////////////////////////////////////////////// // Function: replace_more_news // Description: Replaces news charactars function replace_more_news ($way, $sourse){ if ($way == 'show'){ /* 01 */ "/[filename=(.*?)]/i", /* 02 */ "/[downloads=(.*?)]/i", /* 03 */ "/[filesize=(.*?)]/i" ); /* 01 */ "<a href=\"img/1\">1</a>", /* 02 */ get_download_values('1', 'downloads'), /* 03 */ get_download_values('1', 'size') ); } } //////////////////////////////////////////// //Function: get_download_values //Description: Gets the size and number of DL for a file function get_download_values($file, $what){ $file_db_file = 'files.txt'; foreach($file_db_content as $single_line){ if($file == $single_line_arr[0]){ return ($what == "size" ? $single_line_arr[1] : $single_line_arr[2]); } } } $output = "[filename=test1]<br />[filesize=test1]<br />[downloads=test1]<br /><br /><br />[filename=test2]<br />[filesize=test2]<br />[downloads=test2]"; $output = replace_more_news ('show', $output); ?>
files.txt
Kod
test1|<nobr>size test 2</nobr>|<nobr>downloads test 1</nobr>|
test2|<nobr>size test 2</nobr>|<nobr>downloads test 2</nobr>|
test2|<nobr>size test 2</nobr>|<nobr>downloads test 2</nobr>|
Z góry dziękuję :-)