NYCPHP Meetup

NYPHP.org

EREG Question

Pete Czech - New Possibilities Group, LLC pete at npgroup.net
Wed Feb 5 10:24:31 EST 2003


Hello:

I'm building an online lottery-type of system.  I use this code to compare two arrays to see how many numbers are correct, coming from a text file:

$trigger=fopen($temp."/".$file, "r");
  $content=fread($trigger, 10024);
  $userid = explode("_", $file);
  $entry_numbers = explode(",", $content);
  $correct_amount = 0;
  foreach($entry_numbers as $a) {
   foreach($number as $n) {
    if ($n == $a) {
     $content = ereg_replace("$a", "<b>$a</b>", $content);  //<------ PROBLEM AREA!!!
     $correct_amount++;
    }  
   }
  }

I want to have each correct number BOLDED in the array, so I can display the results to the user.  IE, if the winning numbers were 3,6,9 and they entered 2,5,9 - 9 would be bolded.

This works, but with SINGLE numbers, they appear bolded all over the place.  So if the person had entered 9,39,49 - all the 9's would be bolded...  BUT, this doesn't happen all over!  Just in certain places with no rhyme or reason.  So one persons entry would be fine, showing the single 9 bolded, while another user would have all their 9's bolded.  Ugh!

Any ideas???

Cheers,

Pete Czech
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20030205/bd8a00af/attachment.html>


More information about the talk mailing list