I need to write a short function to dynamically generate a few very basic pages. At the top of the file I will have an array that lists all of the current pages. Then I need the function to create a page for each item in the array. Here are the items that the page will generate:
$appArray = array('testAppOne', 'testAppTwo', 'testAppThree');
$fileName = 'info-'.$appName.'html';
$appLogo = 'path/logo.png';
$appName = appArray[1];
$src = '<!DOCTYPE html><html><head></head><body><img src='".$appLogo."'><h1>'.$appName.'</h1></body></html>'
So would I create a foreach statement to iterate through the array and $fwrite each file to the specific directory? Or is there a better way to approach this?
I’m aware this would be much easier if we used a database, but we’re trying to avoid that for now.
I can’t imagine why you’d want to do this instead of using some dynamic page generation mechanism (i.e. a database), but given the constraints of what you’re asking, yes, I think that would be the best way to go. Something like this: