How is your file delimited? This could impact on whether elemdata is a string
or actually a real array.
That may not be helpful, but here's a handy tip when using file() - remember
that it retains the newline character, so you have to be careful about mixing
and matching dos/windows type files with unix variants!
Brian Higgins wrote:
> Perhaps the php gurus can help with my problem.
>
> I am using php4.0 +windows NT 4.0+Apache to read data from a text file ( a
> list of real numbers). I need to have the the data in the form
> {data1,data2,data3,...,0}. Here is some code:
>
> $elemdata=file("noisydata.dat");
> $number=count($elemdata);
> $stringdata="{";
> for ($i=0;$i<$number;$i++){
> $stringdata.=$elemdata[$i].",";
> }
> $stringdata.="0}";
>
> So far so good.
>
> Now I need to add this data as a query string to a url:
>
> $url="http://www......?stringdata=$stringdata";
>
> and then read the output back into the browser
>
> $fp1=file($url);
> $x=0;
> while($fp1[$x])
> echo $fp1[$x++];
>
> When I use this approach I get a file handler error. I found that I can get
> around the problem by replacing the line
> $stringdata.=$elemdata[$i].",";
> with
> $stringdata.=(string)(real)$elemdata[$i].",";
>
> What gives? In the first instance $elemdata is already string. Why must I go
> through two type cast changes to get this to work! I would really like to
> know the reason behind this quirk.
>
> Thanks much
>
> Brian
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]