I'm making a page were I pull in job postings. Basically, I'm pulling the job info from one file using php. When there are no jobs to be posted I want the div and it's header text to not appear on the page. Which I got to work, my problem is that I have to leave one file in the folder so that I can keep a job template in there so I can copy/paste it when a new job comes in without having to type it out every time. But with that one file in the folder it wants to post a job to the page. I need it to ignore this one file and not display it (The files title is "Template.php").
How do I make it so if there is only the "Template.php" file in the "positions.php" it does not display on the webpage?
Right now I'm using if (count($folder) === 1) { echo ''; } else { echo '<h2 class="job-category">Job Position</h2>'; }
but that is only for the div containing my H2 text, not the whole div and I want to specifically be able to exclude the "Template.php" file
$folder = (glob("positions/*.php")) ;
if (count($folder) === 1) {
echo '';
}
else {
echo '<h2 class="job-category">Job Position</h2>';
}
foreach(array_chunk($folder , 1 ,true)as $filename)
{
echo '<div class="job-posting">' ;
foreach ($filename as $position)
include $position;
}
echo '</div>';
}
Aucun commentaire:
Enregistrer un commentaire