I’m trying to convert the variable name to all lower case, in an echo statement. For example:
$categories = array('1'=>'Holiday') foreach ($categories as $categoryId => $category) { echo "<div class="container"> <a href="category.php?categoryId=$categoryId"> <img src="images/categories/strtolower($category).jpg" alt="holiday turkey" class="image"> <div class="overlay"> <div class="text">$category</div> </div> </a> </div> ";}
I want to convert the variable name to all lowercase, so I can get the picture. I tried just changing the name of the image to Holiday.jpg but I wanted to know if this is possible…
Thank you in advance!
Advertisement
Answer
$categories = array('1'=>'Holiday') foreach ($categories as $categoryId => $category) { echo "<div class='container'><a href='category.php?categoryId=$categoryId'> <img src='images/categories/".strtolower($category).".jpg' alt='holiday turkey' class='image'> <div class='overlay'> <div class='text'>$category</div> </div> </a> </div>"; }