Yet another HTML in PHP question...

So I am working on a PHP project and I've ran into a syntax headache.

Assume $library is a multidimensional array and that all other variables are defined properly.

How do I syntax the following code (it's ugly, I know):

<?php for ($row = 0; $row < $library_size; $row++) {
echo '<option value="'${library[$row]["book_directory"]}'/terms.php">'${library[$row]["nice_name"]}'</option>
} ?>

To print this:
<option value="book_directory/terms.php">Book Nice Name</option>


  • Tyler Postle
    • CGO

    Hey again Sean,

    Hope you're doing well today and thanks for another question!

    PHP isn't one of my strong points yet, so I will flag this for one of our SLS(coding experts) staff - they will be able to provide more accurate feedback on this for you :slight_smile:

    Keep in mind that SLS usually deal with more complex tickets so may take a little longer to respond that the average ticket. In the meantime, feel free to throw any other questions at us!

    Have a great weekend.

    All the best,

  • Ash
    • WordPress Hacker

    Hello @Sean

    I am not sure how your multi dimensional array is configured, but you can try this:

    <?php for ($row = 0; $row < $library_size; $row++) { ?>
    <option value="<?php echo $library[$row]['book_directory'] ?>/terms.php"><?php echo $library[$row]['nice_name'] ?></option>
    <?php } ?>

    Hope it helps :slight_smile: Please feel free to ask more question if you have.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.