Jump to content

Hello, how to make this go from one item to the next?


11Tami

Recommended Posts

Hi, how do I make this go from one item to the next every second? It's not liking the end of my code. Please let me know, thanks very much.

 

<?php 
ini_set('error_reporting', 8191);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
$a = date('s');
$maximum=10;
$text[1] = "test1"; 
$text[2] = "test2"; 
$text[3] = "test3";
$text[4] = "test4";
$text[5] = "test5";
$text[6] = "test6";
$text[7] = "test7";
$text[8] = "test8";
$text[9] = "test9";
$text[10] = "test10";
$text++;
while($maximum>10){$text[1];}
echo "$text[a]"
?> 

You can't increment an array like that and maximum never changes, you have to increment the index. I think you are looking for something like:

for($i=0;$i<$maximum;$i++)
echo $text[$i];

 

If you want to delay execution time, you can use the sleep() function:

for($i=0;$i<$maximum;$i++)
{
echo $text[$i];
sleep(1);
}

Sure am, also forgot to put this right above the array, thanks.

 

$text = Array();

 

<?php 
ini_set('error_reporting', 8191);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
$a = date('s');
$maximum=10;
$text = Array();
$text[1] = "test1"; 
$text[2] = "test2"; 
$text[3] = "test3";
$text[4] = "test4";
$text[5] = "test5";
$text[6] = "test6";
$text[7] = "test7";
$text[8] = "test8";
$text[9] = "test9";
$text[10] = "test10";
$text++;
while($maximum>10){$text[1];}
echo "$text[a]"
?>  

 

 

 

Thanks, I'm not updating the browser, a page refresh is being done. Its to change to a new second only on the second that the page refreshes or loads.

 

At second 1 I need it to be should be showing "testone" etc. one at a time, not all at seconds at once.

 

<?php 
ini_set('error_reporting', 8191);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
$a = date('s');
$maximum=10;
$text = Array();
$text[1] = "testone"; 
$text[2] = "testtwo"; 
$text[3] = "testthree";
$text[4] = "testfour";
$text[5] = "testfive";
$text[6] = "testsix";
$text[7] = "testseven";
$text[8] = "testeight";
$text[9] = "testnine";
$text[10] = "testten";
$text++;
for($i=0;$i<$maximum;$i++)
echo $text[i].$a; 
?>  

Assuming you are using the system clock to determine when to change the page, theoretically you could sync the two, but not in a very efficient manner. The simplest way to do this is to change the javascript to put variable into the URL depending on the previous one.

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.