Array loop help

From: Date: Fri, 10 May 2002 02:02:25 +0000
Subject: Array loop help
Groups: php.general 
Request: Send a blank email to php-general+get-96891@lists.php.net to get a copy of this message
Can someone offer any help with the code below? I have a cookie that is set and is separated by pipes (|). For each segment, I have to look up the id in a text file. I can loop through the cookie and get each segment, but when I open the text file and loop through it, it only matches the first segment. Any help is appreciated. <? if(!IsSet($HTTP_COOKIE_VARS["test"])){
        setcookie("test", "43|50|77|84|", time()+31536000); /* expire in 1 year */
} $myCookie = explode("|",$HTTP_COOKIE_VARS["test"]); foreach ($myCookie as $v){
        echo $v . " ";
        $links_database = "c:\\program
        files\\web_dev\\apache\\htdocs\\link.db";
        $fd = fopen($links_database, "r");
        $contents = fread($fd, filesize($links_database));
        $cookieInfo = explode("|", $contents);
        //foreach ($cookieInfo as $a){
        while(list($key, $value) = each($cookieInfo)){
                if($v == $cookieInfo[0]){
                        print "Link Info: $cookieInfo[1]\n<br>";
                }
        }
        fclose($fd);
} ?> Thanks Chris

« previous php.general (#96891) next »