Re: question about switch function

From: Date: Thu, 07 Feb 2002 21:01:43 +0000
Subject: Re: question about switch function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83911@lists.php.net to get a copy of this message
try it like this: switch(true){ case strstr($line,"zip"): echo "found zip"; break; } On Thu, 7 Feb 2002 14:29:45 -0600, Chuck Barnett wrote: >Hello, I am trying to find out if a string is in a line being read >from a >file. I should use strstr for this I am pretty sure. >I want to do something like this: switch(strstr($line, case >argument)) but >I don't know if it is possible. For example, I am looking for Zip >in a line >but it will not find it using the code below. Any suggestions? I >know I am >being as clear as mud on this :) > >$fd = fopen("mls1.txt", "r"); >while(!feof($fd)) > { > $line=fgets($fd, 4096); > switch($line) > { > case "Zip": > echo "found zip"; > //$line2=fgets($fd,4096); > $zip=$line; > break; > > case "Remarks": > //$line2=fgets($fd,4096); > $neighborhood=$line; > break; > > case "Taxes": > //$line2=fgets($fd,4096); > $address=$line; > break; > > } > > } >fclose($fd); > >

« previous php.general (#83911) next »