FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Heredoc print to file? Use nowdoc.
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Heredoc print to file? Use nowdoc. [message #172123 is a reply to message #172118] Mon, 31 January 2011 07:31 Go to previous messageGo to previous message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma:
Member
"Jerry Stuckle" wrote in message
news:ii5eo4$ov7$1(at)news(dot)eternal-september(dot)org...

> First of all, don't try to compare PHP an Perl. They are two
> different languages, and what you can do in one may or may
> not be done in the other (and it goes both ways).

Yes, I can see that, and it has been a learning experience doing the same
thing (which should be possible) in different ways (due to the language
differences). Now I'm having some difficulty with arrays, but I think I
found how to do what I want, although it seems ridiculous. I modified an
example in the manual to get this:

$qAll = "SELECT * FROM tEntries";
$result = $db->query($qAll);
$row = array("myArray");
$i = 0;
while($res = $result->fetcharray(SQLITE3_BOTH)){
if(!isset( $res['eid'] )) continue;
$row[$i][0] = $res[0];
$row[$i][1] = $res[1];
$row[$i]['et'] = $res['et'];
$i++;
}
print_r($row);
$maxrow = $i-1;
for($i=0; $i<$maxrow; $i++) {
fwrite( $fLog, "{$row[$i][0]} {$row[$i][1]} {$row[$i]['et']}\n");
fwrite( $fLog, "$row[$i][0] $row[$i][1] $row[$i]['et']\n");
}

I can't understand why you can assign an array element $row[$i][0] =
$res[0]; which is a simple scalar quantity (in this case an integer), but
when you use the same expression to write or print, it shows: Array[0], and
the curly braces are needed to extract to actual value. I only found this
deep in the user-supplied examples for arrays, and one would think this is
important enough to include in the main documentation.
http://www.php.net/manual/en/language.types.array.php

I didn't see anything in the array operators:
http://www.php.net/manual/en/language.operators.array.php

It’s not in operator precedence:
http://www.php.net/manual/en/language.operators.precedence.php

I did a search for php curly braces:
http://cowburn.info/2008/01/12/php-vars-curly-braces/

And from that I found this:
http://php.net/manual/en/language.types.string.php

So, now that I know this, I can proceed. It's probably still better than
Perl's various uses of $, %, #, and (), [], {}. Then you can throw in the @
operator and -> and => and all the other ASCII characters for a real
alphabet soup. OK, I'll stop complaining now. But I feel almost like the
victim of a joke, and I think I'll be fooled a few more times before I get
this project working.

:)

Paul
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Unable to connect to database server!
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 01:49:29 GMT 2024

Total time taken to generate the page: 0.03137 seconds