Jump to content

PHP Content Rotator Question


solrman

Recommended Posts

I am trying to get the following (what should be a simple code) to work.

What the code is supposed to do is rotate html files within the page to

keep different content rotating

 

1st part is the php file i am trying to run,

2nd part is the "Include" code I insert on the page I want to run it;

 

Can someone diagnose where I am going wrong with this?

I keep getting unexpected ")" on line 10 of rand_article.php

 

Here are the codes I am using - any assistance would be much appreciated.

 

//random_article.php//

 

1 <?php

2 function randomarticle () {

3 $article = array(

4 'articles/article001.html',

5 'articles/article002.html',

6 'articles/article003.html',

7 'articles/article004.html');

8

9 $random = rand(0, count($article) - 1);

10 return($article[$random]);

11 }

12 ?>

 

code I insert onto the .php page

 

<? include_once("random_article.php"); ?>

 

 

I know I am close but I cannot figure out what i am not doing correctly.

 

Thanks again for any assistance.

Link to comment
https://forums.phpfreaks.com/topic/158351-php-content-rotator-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.