...

View Full Version : php number sequence - range?



AshleyQuick
03-03-2005, 08:27 PM
I'm simply trying to come up with a way to display numbers in a sequence, starting with one (similar to a numbered list - <ol> - in html). The difference is that I want to retrieve the numbers at different point throughout the page...there will be various content between each in other words. Below is what I've come up with thus far, which doesn't work properly. Also, is there a way to make it so that there isn't a limit in the range?


<html>
<head>
<title>Untitled</title>
</head>

<body>

<?php
foreach (range(0, 100) as $number) {
}

?>

<p><?php echo $number ?></p>

<p>content a</p>

<p><?php echo $number ?></p>

<p>content b</p>

<p><?php echo $number ?></p>

</body>
</html>

AaronW
03-03-2005, 08:58 PM
<?
$number = 0;
?>

..
<p><?=++$number?></p>
...
<p><?=++$number?></p>
...
<p><?=++$number?></p>


Like that?

AshleyQuick
03-03-2005, 09:03 PM
Exactly! Thank you. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum