Multi purpose random ad or affiliate generator

One of the things that I know a lot of people struggle with is keeping track of their ads or affies, and making sure that links are up to date all over their site. With this little snippet of code, you only have to edit one set of codes, and the Ads or Affies list will be updated everywhere on your site.
An added bonus of this nifty code – if you only want to show 2 links in one place, but all the links in another, you can.
The first part of the code is where you need to edit your affies/ads. Create a new file and call it ads.php. Then copy the following codes into the file, and edit the links and images to match the ones you want. Feel free to edit the style of the links (make it a text link, use a class or span, etc.) just make sure that you escape any necessary characters.
This file will need to be saved in the root directory as ads.php.

The next code you can put wherever you want the list of affiliates or advertisers to show up. If you edit the number 4, you can control how many ads to show at a time. For example, putting “2″ means only 2 of the 4 ads will be randomly displayed. If you’d like to display all the posts, then leave the number area blank.