/    Sign up×
Community /Pin to ProfileBookmark

putting a buch of values into an array

[code=php]
preg_match(“!Watched&nbsp;By&nbsp;Count:</B> </td>s+<td class=”BoardRowB”>([0-9,]+)s!s”, $file_replace, $match);//grabs the WUL portion[/code]

ok i have statement that retrieves everything i want into $match[1]. Now i want to put all those values into an array so i can arsort() them is this possible?

to post a comment
PHP

45 Comments(s)

Copy linkTweet thisAlerts:
@JonaApr 23.2004 — [font=arial]$match is the array. [url=http://php.net/preg_match]See the manual[/url].[/font]

[code=php]
arsort($match);
[/code]
Copy linkTweet thisAlerts:
@ConorauthorApr 23.2004 — yes i know but there are many match[1]'s . I dont need to sort the match array, i need to put all the values of match[1] coming out of the foreach loop into its own aray so i can do arsort($newarray, SORT_NUMERIC)

also i keep getting this error

Fatal error: Maximum execution time of 30 seconds exceeded in C:Program FilesApache GroupApache2htdocstestign.php on line 22

anyway to change the max ececution time
Copy linkTweet thisAlerts:
@JonaApr 23.2004 — [font=aria]Set a variable to an empty array then append to that variable using $varname[] = $match[1]; in the foreach loop. Show me the code with the foreach loop as well and I can help you more.[/font]
Copy linkTweet thisAlerts:
@JonaApr 23.2004 — [i]Originally posted by RefreshF5 [/i]

[B]Fatal error: Maximum execution time of 30 seconds exceeded in C:Program FilesApache GroupApache2htdocstestign.php on line 22



anyway to change the max ececution time [/B]
[/QUOTE]


[font=arial]You shouldn't need to change the maximum execution time, as doing so will probably overload any kind of server you can put it on. You must be doing an extremely massive for loop or something to get that result. In any case, you can change that in the php.ini file.[/font]
Copy linkTweet thisAlerts:
@ConorauthorApr 23.2004 — ok thanks heres my code in the foreach loop

[code=php]
foreach($user as $x =>$value) //performs foreach so we can eventually echo all users in mu
{

$file=file_get_contents("http://users.ign.com/about/".$value." ");//grabs user profile
$file_replace=str_replace(",","",$file);//replaces comma with nothing for later



preg_match("!Watched&nbsp;By&nbsp;Count:</B> </td>s+<td class="BoardRowB">([0-9,]+)s!s", $file_replace, $match);//grabs the WUL portion
if(eregi($value."'s profile is currently not available.", $file))/*checks if user is
banned and then performs statements to see what to set $wul to*/
{
$wul="Banned";
}
else
{
$wul=$match[1];

}
if($wul=="Banned")
{
$prev="Banned";
}
elseif($previous[$x]=="")
{
$prev="New";
}
else
{
$prev=$match[1]-$previous[$x];
}
echo"[b][li]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;New[/b][b][color=red]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$value."[/b][/color][b][color=green]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$wul."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[/color][color=blue]".$prev."[/b][/color][/li]<br>";
//^^ echoes out final MU code
}

echo"[/ol]";
}
[/code]
Copy linkTweet thisAlerts:
@JonaApr 23.2004 — [code=php]
$ary = array();

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);

if($match[1]){
$ary[] = $match[1];
}

if(eregi($value."'s profile is currently not available.", $file)){
$wul="Banned";
} else {
$wul=$match[1];
}
if($wul=="Banned")
{
$prev="Banned";
}
elseif($previous[$x]==""){
$prev="New";
} else {
$prev=$match[1]-$previous[$x];
}
echo "[.b][li]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;New[/b][.b][color=red]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$value."[/b][/color][.b][color=green]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$wul."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[/color][color=blue]".$prev."[/b][/color][/li]<br>";
# take the dots out from before the b's above
}
echo "[/ol]";
}

arsort($ary);
echo ("<pre>nn");
print_r($ary);
echo ("nn</pre>");
[/code]
Copy linkTweet thisAlerts:
@ConorauthorApr 23.2004 — that works it gives me this


Array

(

[1] => 1920

[0] => 44

)

thanks but im not really familiar with this coding is there anyway to only get the #
Copy linkTweet thisAlerts:
@JonaApr 23.2004 — [i]Originally posted by RefreshF5 [/i]

[B]is there anyway to only get the # [/B][/QUOTE]


[font=arial]What number?[/font] :p
Copy linkTweet thisAlerts:
@ConorauthorApr 23.2004 — like the 1920 and 44 since id like to incorporate that into my origninal script. where the $wul value is in the final output i would like the $ary value so the top # will be the highest.
Copy linkTweet thisAlerts:
@JonaApr 23.2004 — [code=php]
$ary = array();

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);

if($match[1]){
$ary[] = $match[1];
}
}
arsort($ary);

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);

if(eregi($value."'s profile is currently not available.", $file)){
$wul="Banned";
} else {
$wul=$match[1];
}
if($wul=="Banned")
{
$prev="Banned";
}
elseif($previous[$x]==""){
$prev="New";
} else {
$prev=$match[1]-$previous[$x];
}
echo "[.b][li]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;New[/b][.b][color=red]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$value."[/b][/color][.b][color=green]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$wul."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[/color][color=blue]".$prev."[/b][/color][/li]<br>";
# take the dots out from before the b's above
}
echo "[/ol]";
}
[/code]
Copy linkTweet thisAlerts:
@ConorauthorApr 23.2004 — hmm im sorry but i dont really understand. That looks the same as my previous code except it looks like its appearing twice and when i run the code it still doesant put the highest on top ?
Copy linkTweet thisAlerts:
@ConorauthorApr 23.2004 — i think what i have to do is put the "$wul" count and $value which is the name in an associative array and arsort() the $wul part?
Copy linkTweet thisAlerts:
@ConorauthorApr 24.2004 — i had it sort of working by throwing another foreach for the $ary array but it messed up because it echoed everything from the other foreach over and over ? heres what i tried.

[code=php]
$ary = array();

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);

if($match[1]){
$ary[] = $match[1];
}
}
arsort($ary);

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);

if(eregi($value."'s profile is currently not available.", $file)){
$wul="Banned";
} else {
$wul=$match[1];
}
if($wul=="Banned")
{
$prev="Banned";
}
elseif($previous[$x]==""){
$prev="New";
} else {
$prev=$match[1]-$previous[$x];
}
foreach($ary as $watch)
{


echo "[.b][li]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;New[/b][.b]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$value."[/b][.b]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$watch."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$prev."[/b][/li]<br>";
# take the dots out from before the b's above
}
}
echo "[/ol]";
}
?>

[/code]
Copy linkTweet thisAlerts:
@JonaApr 24.2004 — [font=arial]What you want to do is go through the foreach statement once to fill in all the values in $ary. Then you want to run the original foreach statement, which would have access the the proper order of the arrays. You'll need to change some of your code in the last code I posted to read from current($ary) instead of $match[1] (and then go to the next() variable at the end of the loop).[/font]
Copy linkTweet thisAlerts:
@ConorauthorApr 24.2004 — What you want to do is go through the foreach statement once to fill in all the values in $ary. Then you want to run the original foreach statement, which would have access the the proper order of the arrays. You'll need to change some of your code in the last code I posted to read from current($ary) instead of $match[1] (and then go to the next() variable at the end of the loop).[/quote]

uggh im so confused, who thought it would be so hard to get stupid #'s to order upside down. Let me try and break it down and maybe you can tell me if what im saying is right and possibly check some code i write up

I would first run this to fill the array?
[code=php]
$ary = array();

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);

if($match[1]){
$ary[] = $match[1];
}
}
arsort($ary);
[/code]

Now this will contain all the correct order of the match[1] values i guess After that im kind of lost with the current($ary) and next stuff at the end of the loop. Something like this?

[code=php]
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);

if(eregi($value."'s profile is currently not available.", $file)){
$wul="Banned";
} else {
$wul=current($ary);
}
if($wul=="Banned")
{
$prev="Banned";
}
elseif($previous[$x]==""){
$prev="New";
} else {
$prev=current($ary)-$previous[$x];
} [/code]


that echoes the same value for every # so thats where i believe the next($ary) would come in? ALso would i have to put the $wul and $value variable into an asscoitive array so the correct user would match the correct name.
Copy linkTweet thisAlerts:
@JonaApr 24.2004 — [i]Originally posted by RefreshF5 [/i]

[B]I would first run this to fill the array?[/b][/quote]


[font=arial]Yes.[/font]

[i]Originally posted by RefreshF5[/i]

[b]so thats where i believe the next($ary) would come in?[/b][/quote]


[font=arial]Yes, at the end of the foreach loop, use next($ary) and it will start on the second one the next time around.[/font]

[i]Originally posted by RefreshF5[/i]

[b] ALso would i have to put the $wul and $value variable into an asscoitive array so the correct user would match the correct name. [/B][/QUOTE]


[font=arial]You could do that, but if you use current() and next(), you probably shouldn't have to.[/font]
Copy linkTweet thisAlerts:
@ConorauthorApr 24.2004 — ok thank you that worked for getting the #s in the right order but now the #'s match just the first username i put in. but i dont know how to do that ?
Copy linkTweet thisAlerts:
@JonaApr 24.2004 — [i]Originally posted by RefreshF5 [/i]

[B]but i dont know how to do that[/B][/QUOTE]


[font=arial]You're being [b]way[/b] too vague. You don't know how to do what?[/font]
Copy linkTweet thisAlerts:
@ConorauthorApr 24.2004 — Ok sorry here is my current code. It orders the #s perfectly but the # does not corespond to the correct. Name and i do not know what i would have to do this. I attempted to also arsort the $user array but that did not work. So i do not know how to get the user to go with the currect $ary value.

[code=php]<?
//WUU Script for the IGN Boards(boards.ign.com) by Conor Hastings(RefreshF5)
error_reporting(E_ALL ^ E_NOTICE);//turns off notices because i need undefined variable
if(isset($_POST['submit']))//checks if submit is set
{
$users=$_POST['users'];//grabs data from textarea
$user_rep=str_replace(" ","",$users);//replaces emtpy spaces with nothing
$user= explode(",",$user_rep);//puts the data into array


$wul_count=$_POST['wul_count'];//grabs previous WUL count
$wul_rep=str_replace(" ","",$wul_count);
$previous=explode(",",$wul_rep);//explodes into array


echo"[b]Rank/Rank Change/[color=whiye]Username[/color]/[color=EDF3FE]WUL Count[/color]/[color=white]WUL Change[/color][/b]";//echoes heading
echo"[ol]<br>";

$ary = array();

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);

if($match[1]){
$ary[] = $match[1];
}
}
arsort($ary);


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);

if(eregi($value."'s profile is currently not available.", $file)){

$wul="Banned";

} else {

$wul=current($ary);

}

if($wul=="Banned")

{

$prev="Banned";

}

elseif($previous[$x]==""){

$prev="New";

} else {

$prev=current($ary)-$previous[$x];

}
echo "[b][li][/b][b][color=white]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$value."[/b][/color][b][color=EDF3FE]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$wul."[/color][color=white]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$prev."[/color][/b][/li]<br>";
# take the dots out from before the b's above
next($ary);

}
echo "[/ol]";
}
?>[/code]
Copy linkTweet thisAlerts:
@JonaApr 24.2004 — [font=arial]Can you give me the form so I can test it?[/font]
Copy linkTweet thisAlerts:
@ConorauthorApr 24.2004 — <b>Input a comma delimited list of usernames. Append new users to the end.</b><br><textarea rows="8" cols="40" name="users"></textarea><br>

<b>Input previous WUL counts delimited by comma. If New leave blank.</b><br><textarea rows="8" cols="40" name="wul_count"></textarea><br>

<input type="submit" name="submit"><br>

That just goes right above the PHP tags where i am running it. You can put any #'s in the second textarea and in the first some valid usernames are RefreshF5,eshold1,carlmmii,bigreddsmurf,FChappa1j

Usually i have to test with at least 5 usernames as it sometimes works with less.
Copy linkTweet thisAlerts:
@JonaApr 24.2004 — [font=arial]It works for me, I think.[/font]

[b]Rank/Rank Change/[color=blue]Username[/color]/[color=orange]WUL Count[/color]/[color=blue]WUL Change[/color][/b][list=1]
  • [b]
  • [*][/b][b][color=blue] RefreshF5[/b][/color][b][color=orange] 1920[/color][color=blue] 1919[/color][/b]

    [b]
  • [*][/b][b][color=blue] eshold1[/b][/color][b][color=orange] 516[/color][color=blue] 514[/color][/b]

    [b]
  • [*][/b][b][color=blue] carlmmii[/b][/color][b][color=orange] 252[/color][color=blue] 249[/color][/b]

    [b]
  • [*][/b][b][color=blue] bigreddsmurf[/b][/color][b][color=orange] 211[/color][color=blue] 207[/color][/b]

    [b]
  • [*][/b][b][color=blue] FChappa1j[/b][/color][b][color=orange] 44[/color][color=blue] 39[/color][/b]

  • [/list]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 24.2004 — it works as in produces everything b ut you see

    eshold 1 is the one with 1920,carlmmii with 516,Fchappa with 252,bigreddsmurf actually has 211 but that was most likely coincidence and RefreshF5 is the one 44. It produces it buit the wrong # corresponds with the username.
    Copy linkTweet thisAlerts:
    @JonaApr 24.2004 — [font=arial]Like this?[/font]

    [b]Rank/Rank Change/[color=blue]Username[/color]/[color=orange]WUL Count[/color]/[color=blue]WUL Change[/color][/b][list=1]
  • [*][b][color=blue] RefreshF5[/b][/color][b][color=orange] 44[/color][color=blue] 39[/color][/b]

  • [*][b][color=blue] eshold1[/b][/color][b][color=orange] 1920[/color][color=blue] 1915[/color][/b]

  • [*][b][color=blue] carlmmii[/b][/color][b][color=orange] 516[/color][color=blue] 511[/color][/b]

  • [*][b][color=blue] bigreddsmurf[/b][/color][b][color=orange] 211[/color][color=blue] 206[/color][/b]

  • [*][b][color=blue] FChappa1j[/b][/color][b][color=orange] 252[/color][color=blue] 247[/color][/b]

  • [/list]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 24.2004 — [i]Originally posted by Jona [/i]

    [B][font=arial]Like this?[/font]



    [b]Rank/Rank Change/[color=blue]Username[/color]/[color=orange]WUL Count[/color]/[color=blue]WUL Change[/color][/b]
    [list=1]
  • [*][b][color=blue] RefreshF5[/b][/color][b][color=orange] 44[/color][color=blue] 39[/color][/b]

  • [*][b][color=blue] eshold1[/b][/color][b][color=orange] 1920[/color][color=blue] 1915[/color][/b]

  • [*][b][color=blue] carlmmii[/b][/color][b][color=orange] 516[/color][color=blue] 511[/color][/b]

  • [*][b][color=blue] bigreddsmurf[/b][/color][b][color=orange] 211[/color][color=blue] 206[/color][/b]

  • [*][b][color=blue] FChappa1j[/b][/color][b][color=orange] 252[/color][color=blue] 247[/color][/b]

  • [/list]
    [/B][/QUOTE]


    yes except i need it have the 1920 with eshold1 on top, then the carlmmii with 516 2nd etc...
    Copy linkTweet thisAlerts:
    @JonaApr 24.2004 — [font=arial]It will sort them based on the order of the usernames, since that is how the $ary array is populated. Change the order of the usernames to get a different result in the list.[/font]

    [b]Rank/Rank Change/[color=blue]Username[/color]/[color=orange]WUL Count[/color]/[color=blue]WUL Change[/color][/b][list=1]
  • [*][b][color=blue] eshold1[/b][/color][b][color=orange] 1920[/color][color=blue] 1915[/color][/b]

  • [*][b][color=blue] carlmmii[/b][/color][b][color=orange] 516[/color][color=blue] 511[/color][/b]

  • [*][b][color=blue] FChappa1j[/b][/color][b][color=orange] 252[/color][color=blue] 247[/color][/b]

  • [*][b][color=blue] bigreddsmurf[/b][/color][b][color=orange] 211[/color][color=blue] 206[/color][/b]

  • [*][b][color=blue] RefreshF5[/b][/color][b][color=orange] 44[/color][color=blue] 39[/color][/b]

  • [/list]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 24.2004 — yes i know if i change the order of the usernames it will order them correctly but isnt there someway to do it automatically as i have a list of about 100 people with no idea which one has the most or least, and the script is there so i dont have to go into every profile to see how to order it.
    Copy linkTweet thisAlerts:
    @JonaApr 24.2004 — [font=arial]Well, I just use a for loop instead of a foreach loop (the second time) and used $users[$i] instead of $value and $ary[$i] instead of the other variables. I've tried a billion different things, but haven't come up with anything, and now I've run out of time to work on it...[/font]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 24.2004 — ok thanks for the help, ill try and figure something out.
    Copy linkTweet thisAlerts:
    @JonaApr 24.2004 — [font=arial]I did what I could, at least... Sorry I couldn't help more right now.[/font]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 24.2004 — its no problem whatsoever. Im very grateful for the help. It just makes me so mad when i see other people do something and i cant figure it out for myself.
    Copy linkTweet thisAlerts:
    @JonaApr 24.2004 — [font=arial]I don't know, if I were you I'd start over again from scratch, but that's just me - when it doesn't work, I start over. This is the way I ended up calculating a list of one million possible six letter passwords earlier today.[/font]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 24.2004 — i had an idea. what if after collecting the data into $ary in the first foreach i did a

    $data[]=array("name" => $value "wul" => $ary)

    and then ran a for loop and did like echo $data[$i][wul];

    would that work, how would i do the for loop?
    Copy linkTweet thisAlerts:
    @JonaApr 24.2004 — [font=arial]There, ya see? That's an idea right there that just might work. Make sure you look at all the array functions, in case there is a more efficient way to do something, such as [url=http://php.net/array_keys]array_keys[/url].[/font]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 24.2004 — just one question how eactly does a for loop work ive never really understood it

    also any idea why this: $data=array("name" => $value "wul" => $ary); is giveing me this error

    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in C:Program FilesApache GroupApache2htdocswuu.php on line 68
    Copy linkTweet thisAlerts:
    @JonaApr 24.2004 — [font=arial]It runs the code inside its braces ({ and }) as many times as specified.

    for($i=0; [b]start at zero[/b] $i < 200; [b]stop at 199[/b] $i++){ [b]add one to $i every time you run[/b]

    This means $i will increment (if it didn't, the for loop would go forever), it originally starts at zero, and it will stop running the code inside after it reaches its maximum limit (200 in this case).[/font]
    Copy linkTweet thisAlerts:
    @JonaApr 24.2004 — [i]Originally posted by RefreshF5 [/i]

    [B]also any idea why this: $data=array("name" => $value "wul" => $ary); is giveing me this error



    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in C:Program FilesApache GroupApache2htdocswuu.php on line 68 [/B]
    [/QUOTE]


    [font=arial]You left out a comma.[/font]

    [code=php]
    $data=array("name" => $value, "wul" => $ary);
    [/code]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 25.2004 — hmm this gave me no output

    [code=php]
    $data[]=array("name" => $user, "wul" => $ary);
    for($i=0; $i < 200;$i++){
    echo $data[$i]["name"];
    }
    [/code]
    Copy linkTweet thisAlerts:
    @JonaApr 25.2004 — [font=arial]Only because you disabled notices. Your code is a little wrong.[/font]

    [code=php]
    for($j=0; $j< count($user); $j++){
    $data[]=array("name" => $user[$j], "wul" => $ary[$j]);
    }
    for($i=0; $i < count($data);$i++){
    echo $data["name"][$i] .": ";
    echo $data["wul][$i] ."<br>";
    }
    [/code]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 25.2004 — hmm that still gave me no output.

    and when i tried this

    [code=php]

    <form action="<?$_SERVER['PHP_SELF'];?>" method="POST">
    <b>Input a comma delimited list of usernames. Append new users to the end.</b><br><textarea rows="8" cols="40" name="users"></textarea><br>
    <b>Input previous WUL counts delimited by comma. If New leave blank.</b><br><textarea rows="8" cols="40" name="wul_count"></textarea><br>
    <input type="submit" name="submit"><br>
    <?
    //WUU Script for the IGN Boards(boards.ign.com) by Conor Hastings(RefreshF5)
    error_reporting(E_ALL ^ E_NOTICE);//turns off notices because i need undefined variable
    if(isset($_POST['submit']))//checks if submit is set
    {
    $users=$_POST['users'];//grabs data from textarea
    $user_rep=str_replace(" ","",$users);//replaces emtpy spaces with nothing
    $user= explode(",",$user_rep);//puts the data into array


    $wul_count=$_POST['wul_count'];//grabs previous WUL count
    $wul_rep=str_replace(" ","",$wul_count);
    $previous=explode(",",$wul_rep);//explodes into array


    echo"[b]Rank/Rank Change/[color=whiye]Username[/color]/[color=EDF3FE]WUL Count[/color]/[color=white]WUL Change[/color][/b]";//echoes heading
    echo"[ol]<br>";

    $ary = array();

    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);

    if($match[1]){
    $ary[] = $match[1];
    }
    arsort($ary);
    for($j=0; $j< count($user); $j++){
    $data[]=array("name" => $user[$j], "wul" => $ary[$j]);
    }
    for($i=0; $i < count($data);$i++){
    echo $data["name"][$i] .": ";
    echo $data["wul"][$i] ."<br>";
    }
    }
    ?>
    [/code]


    it gives me

    Parse error: parse error, unexpected $end in C:Program FilesApache GroupApache2htdocswuu.php on line 44
    Copy linkTweet thisAlerts:
    @JonaApr 25.2004 — [code=php]
    <form action="<?$_SERVER['PHP_SELF'];?>" method="POST">
    <b>Input a comma delimited list of usernames. Append new users to the end.</b><br><textarea rows="8" cols="40" name="users"></textarea><br>
    <b>Input previous WUL counts delimited by comma. If New leave blank.</b><br><textarea rows="8" cols="40" name="wul_count"></textarea><br>
    <input type="submit" name="submit"><br>
    <?
    //WUU Script for the IGN Boards(boards.ign.com) by Conor Hastings(RefreshF5)
    error_reporting(E_ALL ^ E_NOTICE);//turns off notices because i need undefined variable
    if(isset($_POST['submit']))//checks if submit is set
    {
    $users=$_POST['users'];//grabs data from textarea
    $user_rep=str_replace(" ","",$users);//replaces emtpy spaces with nothing
    $user= explode(",",$user_rep);//puts the data into array


    $wul_count=$_POST['wul_count'];//grabs previous WUL count
    $wul_rep=str_replace(" ","",$wul_count);
    $previous=explode(",",$wul_rep);//explodes into array


    echo"[b]Rank/Rank Change/[color=whiye]Username[/color]/[color=EDF3FE]WUL Count[/color]/[color=white]WUL Change[/color][/b]";//echoes heading
    echo"[ol]<br>";

    $ary = array();

    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);

    if($match[1]){
    $ary[] = $match[1];
    }
    arsort($ary);
    for($j=0; $j< count($user); $j++){
    $data[]=array("name" => $user[$j], "wul" => $ary[$j]);
    }
    for($i=0; $i < count($data);$i++){
    echo $data[$i]["name"] .": ";
    echo $data[$i]["wul"] ."<br>";
    }
    ?>
    [/code]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 25.2004 — i still get this after i submit the form

    Parse error: parse error, unexpected $end in C:Program FilesApache GroupApache2htdocswuu.php on line 42
    Copy linkTweet thisAlerts:
    @JonaApr 25.2004 — [code=php]
    <form action="<?$_SERVER['PHP_SELF'];?>" method="POST">
    <b>Input a comma delimited list of usernames. Append new users to the end.</b><br><textarea rows="8" cols="40" name="users"></textarea><br>
    <b>Input previous WUL counts delimited by comma. If New leave blank.</b><br><textarea rows="8" cols="40" name="wul_count"></textarea><br>
    <input type="submit" name="submit"><br>
    <?
    //WUU Script for the IGN Boards(boards.ign.com) by Conor Hastings(RefreshF5)
    error_reporting(E_ALL ^ E_NOTICE);//turns off notices because i need undefined variable
    if(isset($_POST['submit']))//checks if submit is set
    {
    $users=$_POST['users'];//grabs data from textarea
    $user_rep=str_replace(" ","",$users);//replaces emtpy spaces with nothing
    $user= explode(",",$user_rep);//puts the data into array


    $wul_count=$_POST['wul_count'];//grabs previous WUL count
    $wul_rep=str_replace(" ","",$wul_count);
    $previous=explode(",",$wul_rep);//explodes into array


    echo"[b]Rank/Rank Change/[color=whiye]Username[/color]/[color=EDF3FE]WUL Count[/color]/[color=white]WUL Change[/color][/b]";//echoes heading
    echo"[ol]<br>";

    $ary = array();

    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);

    if($match[1]){
    $ary[] = $match[1];
    }
    }
    arsort($ary);
    for($j=0; $j< count($user); $j++){
    $data[]=array("name" => $user[$j], "wul" => $ary[$j]);
    }
    for($i=0; $i < count($data);$i++){
    echo $data[$i]["name"] .": ";
    echo $data[$i]["wul"] ."<br>";
    }
    }
    ?>
    [/code]
    Copy linkTweet thisAlerts:
    @ConorauthorApr 25.2004 — thank you that fixed the error but no longer retrieves the # count from the profiles. hmm, i wonder why it worked with the foreach but not this.
    Copy linkTweet thisAlerts:
    @ConorauthorApr 25.2004 — also tried cutting my code down to this with the same result of no WUL count
    [code=php]
    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);

    if($match[1]){

    $ary[] = $match[1];

    }
    }
    arsort($ary);
    for($j=0; $j< count($user); $j++){

    $file=file_get_contents("http://users.ign.com/about/".$data[$i]["name"]." ");
    preg_match("!Watched&nbsp;By&nbsp;Count:</B> </td>s+<td class="BoardRowB">([0-9,]+)s!s", $file_replace, $match);
    $data[]=array("name" => $user[$j], "wul" => $ary[$j]);

    }

    for($i=0; $i < count($data);$i++){

    echo $data[$i]["name"] .": ";
    echo $data[$i]["wul"] ."<br>";
    }
    }
    [/code]
    ×

    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,
    )...