Jump to content

If $i >= 10, $i = 10....


newbtophp

Recommended Posts

I have the following code, which arranges an array of numbers in numerical order, and outputs another array.

 

How do i turn for every 10 $i's $i = 1, so say if $i = 20, $i would be 2, if $i was 6 $i would be 1, if $i was 30, $i would be 3, if $i was 1 it would remain 1....

 

<?php
$ids = array('90', '96');
//sort them in numerical order...
sort($ids, SORT_NUMERIC);

$i = 0;
$x = 0;
$New = array();
foreach($ids as $v)
{
$i++;
$x++;
if($i < 10){
$i = 1; 
}
$New[$v] = "&pg=$i#$x";
}
?>

 

Sorry for bad description, sort of lost myself on how to describe it lol

Link to comment
https://forums.phpfreaks.com/topic/200466-if-i-10-i-10/
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.