Re: Help Needed with CSV & PHP

From: Date: Thu, 06 Jul 2000 00:47:56 +0000
Subject: Re: Help Needed with CSV & PHP
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-5120@lists.php.net to get a copy of this message
Hello Rasmus, Rasmus Lerdorf wrote: > PHP's strings are fully binary safe, so you could actually replace the > user-supplied : with a \0 and then change them back > afterwards. Presumably there is no way for the user to type ascii code 0 > into a text field. > $new = str_replace(':',chr(0),$old); This is an innovative approach. I think that it will be the crispest way to resolve the problem. Unfortunately, I have one problem. I can write the user entered ':' to the file, without dificulty, but I'm not sure if there is an easy way to retrieve it from the file using my existing script. Is there a way to integrate your str_replace suggestion with the strtok command? Would something like this work: echo "$tok(str_replace(chr(0),':',$tok))</a>\n</td>\n</tr>\n"; I'm looking for a command that would take a field $tok and replace elements within it in a single go. This is the complete script: $tok = strtok($dataarray[$viewcard-1],":"); while($tok){ if ($httpcounter == 0) { echo ""; } elseif($httpcounter == 1){ echo "<table BORDER=0 WIDTH=\"100%\">\n<tr>\n<td ALIGN=CENTER VALIGN=TOP>\n<IMG src=\"graphics/$tok\">\n</td>\n"; } elseif ($httpcounter == 2) { echo "<td VALIGN=TOP>\n<table BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=2 WIDTH=\"100%\">\n<tr>\n<td>\n<b>To:</b>\n</td>\n<td>\n<a href=\"mailto:$tok\">"; } elseif ($httpcounter == 3) { echo "$tok</a>\n</td>\n</tr>\n"; } elseif ($httpcounter == 4) { echo "<tr>\n<td>\n<b>From:</b></td>\n<td>\n<a href=\"mailto:$tok\">"; } elseif ($httpcounter == 5) { echo "$tok</a>\n</td>\n</tr>\n</table>\n"; } elseif ($httpcounter == 6) { echo "<B>Message:</B><BR>$tok</td>\n</td>\n</tr>\n</table>\n"; } else { } $tok = strtok(":"); $httpcounter++; } Mike -- Mike A. Gifford OpenConcept Consulting Mike@OpenConcept.On.Ca Http://www.OpenConcept.On.Ca Web Design, Hosting, Graphic Design & Site Promotion Featured Site --> Http://WTOAction.Org

« previous php.general (#5120) next »