/    Sign up×
Community /Pin to ProfileBookmark

probably simple question, i want something to count #’s

<?
$user= array(“RefreshF5″,”eshold1″,”carlmmii”);
$previous= array(“25″,”20″,”16”);

foreach($user as $x =>$value)
{
$file=file_get_contents(“http://users.ign.com/about/”.$value.” “);
$file_replace=str_replace(“,”,””,$file);

preg_match(“!Watched&nbsp;By&nbsp;Count:</B> </td>s+<td class=”BoardRowB”>([0-9,]+)s!s”, $file_replace, $match);
$prev=$match[1]-$previous[$x];
echo”[b] [color=red]“.$value.”[/b][/color][b][color=green]“.$match[1].”[/b][/color]“.$prev.”<br>”;

}
?>

ok i have this script for something and i wnat a rank at the beginning. So i want to count the array and echo a number for how many usernames there are. So like now there are 3 usernames so it would be
1
2
3

dont know if this makes sense but HELP Please

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@pyroApr 22.2004 — Not sure what you are looking for. If the usernames are all in an array, why not just use [URL=http://www.php.net/manual/en/function.count.php]count[/URL]?
Copy linkTweet thisAlerts:
@ConorauthorApr 22.2004 — yeah i need a # for each username. like the first will be 1. and etc. Count only gave me one value, like if there 3 values in an array it would only give me "3" not one on the first person 2 on the second and 3 on the third like a list. I basically need to make a list but cant youe <ol> because when you highlight the text with that it doesnt copy the 1,2,3 etc...
Copy linkTweet thisAlerts:
@pyroApr 22.2004 — How about something like this, then?

[code=php]<?PHP
$array = array('one', 'two', 'three');
for ($i=0; $i<count($array); $i++) {
echo "$i $array<br />";
}
?>[/code]
Copy linkTweet thisAlerts:
@ConorauthorApr 22.2004 — a for loop doesnt work because if i run that inside the foreach it would echo out everything that # of times so right now if i put in "RefreshF5,eshold1" it will output

[b] [color=red]RefreshF5[/b][/color][b][color=green] 44[/b][/color] New

[b] [color=red]eshold1[/b][/color][b][color=green] 1920[/b][/color] New

if i ran the for loop it would echo everything twice and it starts with 0 not 1 like i need it to.
×

Success!

Help @Conor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...