miccomte Posted March 15, 2010 Share Posted March 15, 2010 Hello, I have difficulties doing the below task with PHP, does anyone can help? I have an HTML file containing some span tags encapsulating numbers: <span>1</span>...<span>10</span>...<span>5</span>...<span>7</span> I would like to replace the numbers with serial number, incremented by 1 for each span: <span>1</span>...<span>2</span>...<span>3</span>...<span>4</span> Any idea? Link to comment https://forums.phpfreaks.com/topic/195332-how-to-number/ Share on other sites More sharing options...
StathisG Posted March 15, 2010 Share Posted March 15, 2010 for ($i=1; $i<5; $i++) { echo '<span>'.$i.'</span>; } Link to comment https://forums.phpfreaks.com/topic/195332-how-to-number/#findComment-1026517 Share on other sites More sharing options...
miccomte Posted March 16, 2010 Author Share Posted March 16, 2010 Thanks, but it will just display <span>1</span><span>2</span><span>3</span><span>4</span>... What I want is to REPLACE something like that: <span>1</span>...<span>10</span>...<span>5</span>...<span>7</span> with something like that: <span>1</span>...<span>2</span>...<span>3</span>...<span>4</span> Link to comment https://forums.phpfreaks.com/topic/195332-how-to-number/#findComment-1027008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.