I have some files named like: fileONE-13 and fileFive-22 etc. I am trying make a php code that does the following: if whatever before the last - = fileONE-, then echo something, and if whatever before the last - = fileFive-, then echo something else.. etc.
However what I have so far just echos the first one only, even if the bookname is different.
<?php
$filename = basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']);
$chapterNo = substr(strrchr($filename, "-"), 1, 2);
$bookname = substr($filename, 0, strrpos($filename, '-'));
if ($bookname = "fileONE-") { echo "This is File 1 - $chapterNo"; }
elseif ($bookname = "fileFive-") { echo "This is File 5 - $chapterNo"; }
?>
Aucun commentaire:
Enregistrer un commentaire