# Arrays and loops

**URL:** <https://forum.kirupa.com/t/arrays-and-loops/244411>\
**Category:** Uncategorized\
**Created:** [November 17, 2007, 5:53pm UTC](https://forum.kirupa.com/t/arrays-and-loops/244411 "2007-11-17T17:53:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![acc](https://avatars.discourse-cdn.com/v4/letter/a/b38774/32.png) [@acc](https://forum.kirupa.com/u/acc)\
**Post date:** [November 17, 2007, 5:53pm UTC](https://forum.kirupa.com/t/arrays-and-loops/244411/1 "2007-11-17T17:53:40Z")

</div>

new to PHP, so I’m learning as I go about creating my websites.

what I’m trying to do is simply create a loop that will create the my buttons (an image for each button)

Here’s what I have, right now simply lists the text of Jan to Dec

```auto

<?
// foreach example - loop through each entry in an array

$month = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

foreach ( $month as $element ) {
  
   echo "$element , ";

}
?> 

```

To create image buttons I use this code

```auto

<img class="imgLink btnArchive" src="/images/btnJan.jpg" onmouseover="(this.src)='/images/btnJan.jpg';" onmouseout="(this.src)='/images/btnJan.jpg';" alt="" />

```

So all I basically want to do is create a loop with the array that will change the image name with the name of the month to display all 12 buttons

I tried this, but I don’t know how to deal with quotations in php and adding array values into code

```auto

echo '<img class="imgLink btnArchive" src="/images/btn &element .jpg" onmouseover="(this.src)='/images/btn &element .jpg;"

onmouseout="(this.src)=/images/btn &element .jpg';" alt="" />'

```

Thanks very much
