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 #172129 is a reply to message #172123] Mon, 31 January 2011 12:34 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 1/31/2011 2:31 AM, P E Schoen wrote:
> "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
>

You can print a scalar quantity, even if it is an array element.
However, if the element is itself an array, you can assign the array buy
not print it. If you're getting Array, you have an array, not a scalar.

But I don't see anything in your sample code which would print Array[0],
so I have no idea what you might actually be doing.

> 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

Your biggest problem is you are still trying to equate PHP to Perl.
It's a HUGE mistake to do that (no matter what the language). Trying to
look for the differences will only confuse you.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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:32:08 GMT 2024

Total time taken to generate the page: 0.04252 seconds