php-general Digest 31 Oct 2009 20:51:04 -0000 Issue 6420

2009-10-31 Thread php-general-digest-help

php-general Digest 31 Oct 2009 20:51:04 - Issue 6420

Topics (messages 299543 through 299546):

mysql resoc iterator
299543 by: viraj

Re: Help with my first recursion menu
299544 by: Lex Braun
299545 by: MEM

Two Parser Passes
299546 by: Daniel Kolbo

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
can somebody point me to a good article or a piece of code on
implementing an iterator for a mysql result resource?

actually this is for an oracle statement handle, all i want is to
fetch the results as it is from a multi dimensional array. so i can
use it in a for each with keys

IteratorAggregate over Iterator seems the best fit for the task as i
do not want seeking back and forth.

thanks!

~viraj
---End Message---
---BeginMessage---
Hi,

On Wed, Oct 28, 2009 at 5:22 PM, MEM tal...@gmail.com wrote:

  I've been told that stack is the way to go, so I'm trying to understand
 the
 following code:
 http://pastebin.com/m5616c88f
 I've commented every line so that any of you could see if I'm interpreting
 something wrong:


 I have two questions about this code, that hopefully someone on the list
 could explain:

 1)
 Why do we need to remove the last array item? (on line 32):
 array_pop($urlStack);

On line 20, $url creates an URL path that includes the $cat path.  Once
you've completed iteration on all children of $cat, the url path should no
longer include $cat path, thus it is removed from $urlStack.



 2)
 Why we print the closed tag of the li element, after the recursive call?
 (on
 line 29)
 echo /li\n;

Line 29 is closing the li element that was opened on line 23 for $cat.



 Thanks a lot in advance,
 Márcio

-Lex
---End Message---
---BeginMessage---
 
From: Lex Braun [mailto:lex.br...@gmail.com] 
Sent: sábado, 31 de Outubro de 2009 14:05
To: MEM
Cc: php-gene...@lists.php.net
Subject: Re: [PHP] RE: Help with my first recursion menu
 
Hi,
On Wed, Oct 28, 2009 at 5:22 PM, MEM tal...@gmail.com wrote:
I've been told that stack is the way to go, so I'm trying to understand the
following code:
http://pastebin.com/m5616c88f
I've commented every line so that any of you could see if I'm interpreting
something wrong:


I have two questions about this code, that hopefully someone on the list
could explain:

1)
Why do we need to remove the last array item? (on line 32):
array_pop($urlStack);
On line 20, $url creates an URL path that includes the $cat path.  Once you've 
completed iteration on all children of $cat, the url path should no longer 
include $cat path, thus it is removed from $urlStack.
 

2)
Why we print the closed tag of the li element, after the recursive call? (on
line 29)
echo /li\n;
Line 29 is closing the li element that was opened on line 23 for $cat.


Thanks a lot in advance,
Márcio
-Lex
 
 
 
 
Thanks a lot. I knew that:
“Line 29 is closing the li element that was opened on line 23 for $cat.”
 
My question intend to be more like:
Why that line to close the li element is *after* the recursive call? 
Somehow, it seems that instead of creating something like this:
ul
liitem1/li
liitem2/li
liitem3/li
/ul
 
We are doing:
ul
liitem1
liitem2
liitem3
/li
/ul
 
Anyway, the main doubt was the first. I will test this and see what I get. 
 
Thanks a lot for your reply.
Regards,
Márcio
 
---End Message---
---BeginMessage---
Hello,

Is it possible to get a list (array) of classes not found in a script
before the fatal error exits the parser.  I realize that PHP parses the
script twice.  It would be nice at the end of the first parsing pass to
check to see which classes haven't been defined (yet), so that I could
define them before the second pass.  This way I could load only those
classes a script needs.

Thanks in advance,
dK
`
---End Message---


Re: [PHP] Textarea to road a text file

2009-10-31 Thread Jean Lee
Yes, I just want to edit a file in the textarea!
thank you.

Jay Blanchard jblanch...@pocket.com wrote in message 
news:31454d514ff9a949b1fdfe294d5d1d80080...@ygex01wal.onecall.local...
[snip]
htmlheadtitle.
body..

?php

$handle = fopen(./menu.php, r);
$contents = ;

if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle);

$contents = $contents . $buffer;
}
fclose($handle);
}

echo textarea cols=80 rows=30 . $contents . /textarea;

?

/body
/html
[/snip]

Try http://us3.php.net/manual/en/function.file-get-contents.php

?php

$contents = file_get_contents('./menu.php');

echo textarea cols=80 rows=30 . $contents . /textarea;

?

I am unsure what you want to do here, display the menu in the textarea?
Or do you want to be able to edit menu.php in the textarea? 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mysql resoc iterator

2009-10-31 Thread viraj
can somebody point me to a good article or a piece of code on
implementing an iterator for a mysql result resource?

actually this is for an oracle statement handle, all i want is to
fetch the results as it is from a multi dimensional array. so i can
use it in a for each with keys

IteratorAggregate over Iterator seems the best fit for the task as i
do not want seeking back and forth.

thanks!

~viraj

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] RE: Help with my first recursion menu

2009-10-31 Thread Lex Braun
Hi,

On Wed, Oct 28, 2009 at 5:22 PM, MEM tal...@gmail.com wrote:

  I've been told that stack is the way to go, so I'm trying to understand
 the
 following code:
 http://pastebin.com/m5616c88f
 I've commented every line so that any of you could see if I'm interpreting
 something wrong:


 I have two questions about this code, that hopefully someone on the list
 could explain:

 1)
 Why do we need to remove the last array item? (on line 32):
 array_pop($urlStack);

On line 20, $url creates an URL path that includes the $cat path.  Once
you've completed iteration on all children of $cat, the url path should no
longer include $cat path, thus it is removed from $urlStack.



 2)
 Why we print the closed tag of the li element, after the recursive call?
 (on
 line 29)
 echo /li\n;

Line 29 is closing the li element that was opened on line 23 for $cat.



 Thanks a lot in advance,
 Márcio

-Lex