Themes

Hi.

How can we create different advertisements in different php pages?

In what context, can you provide an example ?

for example let’s say I have 10 pages. In page 1,2,3 an adevtisement appears and in page 4,5,6 another adevertisment appears. I want easily to control the the advertisments through uploading images. I aslo want to be able to disable advertisments in pages 7,8,9 for temporary perioud till I activate them

Something like this?


<?php
$adverts = array(
  'home'  => array(
    'active'  => true,
    'image'   => 'assets/img/facebook.png'
  ),
  'contact'  => array(
    'active'  => false,
    'image'   => 'assets/img/yahoo.png'
  )
);

function render_ad($page, $adverts){
  if(false === array_key_exists($page, $adverts) || false === $adverts[$page]['active']){
    return '';
  }
  return sprintf('<img src="%s" class="ad" alt="#" />', $adverts[$page]['image']);
}

echo render_ad('home', $adverts);
?>

Wow! :wink: many thanks.

I have a question hope you answer it, now who improves PHP, Zend company or others? let’s say that Zend stopped its business, does this mean that PHP will stop?

Thanks. :smiley:

The community, as always.

So even if I don’t care about Zend at all, I still can do alot of professional PHP programming!

Indeed you can, but caring is encouraged.