OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 29 Oct 2007 23:33:11 -0000 Issue 5099

php-general-digest-helplists.php.net
Date: Mon Oct 29 2007 - 18:33:11 CDT


php-general Digest 29 Oct 2007 23:33:11 -0000 Issue 5099

Topics (messages 263771 through 263793):

Re: moving over to php 5
        263771 by: Dave Goodchild
        263778 by: Per Jessen
        263782 by: Cristian Vrabie
        263784 by: Philip Thompson
        263785 by: Robert Cummings
        263786 by: Robert Cummings
        263788 by: Per Jessen
        263793 by: Larry Garfield

Re: Newline
        263772 by: Crayon Shin Chan
        263774 by: Nathan Nobbe
        263775 by: Jeremy Mcentire

what is the point of prepare?
        263773 by: Hulf
        263776 by: Per Jessen
        263777 by: Jeremy Mcentire
        263792 by: mlists

Re: sessions (version 5.1 to 5.2 )
        263779 by: tedd

problem with bind_param
        263780 by: Hulf
        263790 by: Jeremy Mcentire

Re: returning an array from a function?
        263781 by: Philip Thompson

unexpected '' in preg_replace???
        263783 by: Zoltán Németh
        263787 by: Daniel Brown
        263791 by: Jim Lucas

Re: SPL
        263789 by: Jim Lucas

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Support for php4 will be dropped at the end of the year so hosts will be
forced to make the upgrade at some point.

On 10/29/07, Hulf <rossblue-fly.co.uk> wrote:
>
> Hi,
>
>
> It is about time I made the jump to 5, however the only thing that is
> holding me back is the problem with hosts. How many hosts still run php 4
> and am I going to have to spend hours and hours persuading them to upgrade
> before I can run my code?
>
> I have very little time as it is and am anxious that this is going to be
> swallowed up on the phone to hosing companies and their rubbish technical
> staff.
>
> Please let me know if I will find this an easy transition or should I hold
> off for now.
>
>
> R.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Hulf wrote:

> It is about time I made the jump to 5, however the only thing that is
> holding me back is the problem with hosts. How many hosts still run
> php 4 and am I going to have to spend hours and hours persuading them
> to upgrade before I can run my code?

There are at least 117,223 hosting companies that are still using PHP4.
Unless they already have an upgrade project going, a single user is
unlikely to convince them to start one.

> Please let me know if I will find this an easy transition or should I
> hold off for now.

As a whole, I think you'll find the 4-5 transition easy. Possible
issues: the xsl extension, which was changed from saxon to libxml, and
the Mailparse extension also caused us some grief. We rewrote the code
to use the new xsl stuff, and somehow we also managed to get Mailparse
installed.

Dave Goodchild wrote:

> Support for php4 will be dropped at the end of the year so hosts will
> be forced to make the upgrade at some point.

What will force them to do so? Lack of support is unlikely to have any
effect.

/Per Jessen, Zürich

attached mail follows:


Per Jessen wrote:
> Hulf wrote:
>
>
>> It is about time I made the jump to 5, however the only thing that is
>> holding me back is the problem with hosts. How many hosts still run
>> php 4 and am I going to have to spend hours and hours persuading them
>> to upgrade before I can run my code?
>>
>
> There are at least 117,223 hosting companies that are still using PHP4.
> Unless they already have an upgrade project going, a single user is
> unlikely to convince them to start one.
>
>
>> Please let me know if I will find this an easy transition or should I
>> hold off for now.
>>
>
> As a whole, I think you'll find the 4-5 transition easy. Possible
> issues: the xsl extension, which was changed from saxon to libxml, and
> the Mailparse extension also caused us some grief. We rewrote the code
> to use the new xsl stuff, and somehow we also managed to get Mailparse
> installed.
>
> Dave Goodchild wrote:
>
>
>> Support for php4 will be dropped at the end of the year so hosts will
>> be forced to make the upgrade at some point.
>>
>
> What will force them to do so? Lack of support is unlikely to have any
> effect.
>
>
>
> /Per Jessen, Zürich
>
>
Hmm 117,223 hosts with php4 only support. Did you actually checked how many have php5 support? Many more. You have hundreds of thousands of choices. And the pricing has quite leveled in the last period or the differences in price are absolutely minor. I don't see a reason to stay with one that only supports php4. After all, changing the adress-ip link on dns is free and it will propagate in a few hours.

attached mail follows:


On 10/29/07, Per Jessen <percomputer.org> wrote:
>
> Hulf wrote:
>
> > It is about time I made the jump to 5, however the only thing that is
> > holding me back is the problem with hosts. How many hosts still run
> > php 4 and am I going to have to spend hours and hours persuading them
> > to upgrade before I can run my code?
>
> There are at least 117,223 hosting companies that are still using PHP4.
> Unless they already have an upgrade project going, a single user is
> unlikely to convince them to start one.
>
> > Please let me know if I will find this an easy transition or should I
> > hold off for now.
>
> As a whole, I think you'll find the 4-5 transition easy. Possible
> issues: the xsl extension, which was changed from saxon to libxml, and
> the Mailparse extension also caused us some grief. We rewrote the code
> to use the new xsl stuff, and somehow we also managed to get Mailparse
> installed.
>
> Dave Goodchild wrote:
>
> > Support for php4 will be dropped at the end of the year so hosts will
> > be forced to make the upgrade at some point.
>
> What will force them to do so? Lack of support is unlikely to have any
> effect.
>
>
> /Per Jessen, Zürich

 I think the real question is.... will listservs (like this one) stop
supporting people running applications on PHP4 in 98 days (
http://gophp5.org/)? I'm not saying we should outcast *those people* who
haven't transitioned, but will the process speed up if a community puts
their foot down? Is this how it will be..................

[example question]
I'm running PHP4 and blah blah blah...

[example response]
Oh, I noticed you said PHP4. Sorry, upgrade, then we'll support...

Just a thought...
~Philip

attached mail follows:


On Mon, 2007-10-29 at 08:52 +0000, Hulf wrote:
> Hi,
>
>
> It is about time I made the jump to 5, however the only thing that is
> holding me back is the problem with hosts. How many hosts still run php 4
> and am I going to have to spend hours and hours persuading them to upgrade
> before I can run my code?
>
> I have very little time as it is and am anxious that this is going to be
> swallowed up on the phone to hosing companies and their rubbish technical
> staff.
>
> Please let me know if I will find this an easy transition or should I hold
> off for now.

Update your code so it works for both PHP4 and PHP5. Then you can
actually make the move whenever you please regardless of what hosting
companies are offering.

Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

attached mail follows:


On Mon, 2007-10-29 at 09:42 -0500, Philip Thompson wrote:
>
> I think the real question is.... will listservs (like this one) stop
> supporting people running applications on PHP4 in 98 days (
> http://gophp5.org/)? I'm not saying we should outcast *those people* who
> haven't transitioned, but will the process speed up if a community puts
> their foot down? Is this how it will be..................
>
> [example question]
> I'm running PHP4 and blah blah blah...
>
> [example response]
> Oh, I noticed you said PHP4. Sorry, upgrade, then we'll support...

Won't hear me making that statement. But then I'm not a snob to PHP4 :)

Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

attached mail follows:


Cristian Vrabie wrote:

> Hmm 117,223 hosts with php4 only support. Did you actually checked how
> many have php5 support? Many more.

There are 178.112 hosters that have PHP5 support. I checked.

> You have hundreds of thousands of choices. And the pricing has quite
> leveled in the last period or the differences in price are absolutely
> minor. I don't see a reason to stay with one that only supports php4.

Nobody suggested that you do - especially if you need PHP5. If however
you don't have a specific requirement for PHP5, why would you move?

/Per Jessen, Zürich

attached mail follows:


On Monday 29 October 2007, Per Jessen wrote:
> Cristian Vrabie wrote:
> > Hmm 117,223 hosts with php4 only support. Did you actually checked how
> > many have php5 support? Many more.
>
> There are 178.112 hosters that have PHP5 support. I checked.

Where and how did you check? Compiling such stats is rather hit or miss, and
the numbers most people quoted until now I have decided are simply wrong.

I have a hard time believing that there are 300,000 different commercial web
hosting companies out there. That many servers, sure, but companies?

--
Larry Garfield AIM: LOLG42
larrygarfieldtech.com ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson

attached mail follows:


On Sunday 28 October 2007, magoo wrote:

> I have switched to using single quotes, and found out that newline (\n)
> only works in double quotes. It looks kind of stupid using
> 'someString'."\n"; and it`s kind of inconsistent using double quotes
> for some lines like "someString\n";.

You can:

        define('LF', "\n");

then

        echo 'A newline' . LF;

or something

--
Crayon

attached mail follows:


On 10/29/07, Crayon Shin Chan <crayon.shin.chan.ukgmail.com> wrote:
>
> On Sunday 28 October 2007, magoo wrote:
>
> > I have switched to using single quotes, and found out that newline (\n)
> > only works in double quotes. It looks kind of stupid using
> > 'someString'."\n"; and it`s kind of inconsistent using double quotes
> > for some lines like "someString\n";.
>
> You can:
>
> define('LF', "\n");
>
> then
>
> echo 'A newline' . LF;
>
> or something

if you were going to do that you may as well use PHP_EOL
its cross-platform and doesnt require an define directive.
(php5 only)

-nathan

attached mail follows:


In general, I try to think of single quotes as being literal and
double quotes as being interpreted.

In that case, we expect 'some line\t with a tab, a variable {$obj-
>member}, and a newline\n' to produce exactly:
some line\t with a tab, a variable {$obj->member}, and a newline\n

Yet, the same thing in double quotes:
some line with a tab, a variable foo, and a
  newline

As a result, I use single quotes whenever I can. Otherwise, double.

Jeremy Mcentire
Ant Farmer
ZooToo LLC

On Oct 29, 2007, at 6:15 AM, Nathan Nobbe wrote:

> On 10/29/07, Crayon Shin Chan <crayon.shin.chan.ukgmail.com> wrote:
>>
>> On Sunday 28 October 2007, magoo wrote:
>>
>>> I have switched to using single quotes, and found out that
>>> newline (\n)
>>> only works in double quotes. It looks kind of stupid using
>>> 'someString'."\n"; and it`s kind of inconsistent using double quotes
>>> for some lines like "someString\n";.
>>
>> You can:
>>
>> define('LF', "\n");
>>
>> then
>>
>> echo 'A newline' . LF;
>>
>> or something
>
>
> if you were going to do that you may as well use PHP_EOL
> its cross-platform and doesnt require an define directive.
> (php5 only)
>
> -nathan

attached mail follows:


Hi,

Begining using the php5 mysql functions and want to know what is the point of preparing/binding the data before I insert it?

$prep = $mysqli->prepare ("INSERT INTO cd (cdid,title,artist) VALUES ('0',?,?)");
$prep->bind_param ('22',$title,$artist);

Ta,

R.

attached mail follows:


Hulf wrote:

> Begining using the php5 mysql functions and want to know what is the
> point of preparing/binding the data before I insert it?
>
> $prep = $mysqli->prepare ("INSERT INTO cd (cdid,title,artist) VALUES
> ('0',?,?)"); $prep->bind_param ('22',$title,$artist);

It's a performance measure - by preparing sql statements, you save on
the parsing and the network traffic. Unless you're doing lots of
database transactions per second, I doubt if you'll notice it.

/Per Jessen, Zürich

attached mail follows:


If you're making just one insert; it's probably not the best
approach. However, if you're inserting multiple rows, benchmarks
have shown that preparing a statement and binding the params is
faster. Also, with mysqli, you can strictly define types for fields
and remove the step of validation -- so they say. I'd rather not try
{} catch{} a query and give an error on failure... so, I prepare the
data as I test its validity anyway.

Jeremy Mcentire
Ant Farmer
ZooToo LLC

On Oct 29, 2007, at 6:06 AM, Hulf wrote:

> Hi,
>
> Begining using the php5 mysql functions and want to know what is
> the point of preparing/binding the data before I insert it?
>
> $prep = $mysqli->prepare ("INSERT INTO cd (cdid,title,artist)
> VALUES ('0',?,?)");
> $prep->bind_param ('22',$title,$artist);
>
> Ta,
>
> R.

attached mail follows:


On Mon, 2007-10-29 at 10:06 +0000, Hulf wrote:
> Hi,
>
> Begining using the php5 mysql functions and want to know what is the point of preparing/binding the data before I insert it?
>
> $prep = $mysqli->prepare ("INSERT INTO cd (cdid,title,artist) VALUES ('0',?,?)");
> $prep->bind_param ('22',$title,$artist);
>
> Ta,
>
> R.

With a prepared statement, you can use mysqli_get_metadata() to get
information about the columns of the result that statement will
generate, without having to actually execute the statement (or parse it
yourself).

This comes in really handy if you have dynamically generated SQL and
need to know what the names/types of the columns are going to be before
you execute it.

Mysqli_get_metadata() also includes info on the original names and
tables of the columns (if they have been aliased) and what their types
are. This is great for generating multi-table insert statements from
dynamically generated SQL queries.

attached mail follows:


>strange. i must be missing something simple.
>
>
>Fritz

I would guess that you did make the first line of your code:

<?php session_start();

http://www.php.net/session_start

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


Hi,

I am still having poblems with the php5 functions. I have 4 variables in
each. What is the problem?

Warning: mysqli_stmt::bind_param() [function.mysqli-stmt-bind-param]: Number
of elements in type definition string doesn't match number of bind variables
in xxxx on line 21

$prep = $mysqli->prepare ("UPDATE events SET title=?, date=?, content=?,
imageUrl=?");
$prep->bind_param ( $_POST['title'], $_POST['date'], $_POST['content'],
$_POST['imageUrl']);

thanks,

H.

attached mail follows:


The PHP docs show:

$stmt = $mysqli->prepare("INSERT INTO CountryLanguage VALUES
(?, ?, ?, ?)");
$stmt->bind_param('sssd', $code, $language, $official, $percent);

for usage. Your $prep->bind_param() doesn't seem to include the
definitions. 'sssd' in the above example, string, string, string,
decimal. Further, you should probably make sure that your $_POST
data is set and isn't null or a variable type other than what is
expected.

Jeremy Mcentire
Ant Farmer
ZooToo LLC

On Oct 29, 2007, at 9:51 AM, Hulf wrote:

> Hi,
>
> I am still having poblems with the php5 functions. I have 4
> variables in
> each. What is the problem?
>
>
> Warning: mysqli_stmt::bind_param() [function.mysqli-stmt-bind-
> param]: Number
> of elements in type definition string doesn't match number of bind
> variables
> in xxxx on line 21
>
> $prep = $mysqli->prepare ("UPDATE events SET title=?, date=?,
> content=?,
> imageUrl=?");
> $prep->bind_param ( $_POST['title'], $_POST['date'], $_POST
> ['content'],
> $_POST['imageUrl']);
>
> thanks,
>
> H.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


On 10/26/07, tedd <tedd.sperlinggmail.com> wrote:
>
> Rob:
>
> Why use a global?
>
> Plus, your function is returning an array, but you're not catching it.
>
> $mve_array = convert( $latitude, $longitude );
>
> Example:
>
> http://www.webbytedd.com/bbb/array-function/
>
> Cheers,
>
> tedd

So... do you write some of these pages on-the-fly when you see someone
needing assistance from the list? or you have this repository of scripts? =D

~Philip

attached mail follows:


hi list,

I have this code:

<?php

$mit = array(
         "/\r/", // Non-legal carriage
return
         "/[\n\t]+/", // Newlines and tabs
         '/[ ]{2,}/', // Runs of spaces,
pre-handling
         '/<script[^>]*>.*?<\/script>/i', // <script>s -- which
strip_tags supposedly has problems with
         '/<style[^>]*>.*?<\/style>/i', // <style>s -- which
strip_tags supposedly has problems with
         '/<h[123][^>]*>(.*?)<\/h[123]>/ie', // H1 - H3
         '/<h[456][^>]*>(.*?)<\/h[456]>/ie', // H4 - H6
         '/<p[^>]*>/i', // <P>
         '/<br[^>]*>/i', // <br>
         '/<b[^>]*>(.*?)<\/b>/ie', // <b>
         '/<strong[^>]*>(.*?)<\/strong>/ie', // <strong>
         '/<i[^>]*>(.*?)<\/i>/i', // <i>
         '/<em[^>]*>(.*?)<\/em>/i', // <em>
         '/(<ul[^>]*>|<\/ul>)/i', // <ul> and </ul>
         '/(<ol[^>]*>|<\/ol>)/i', // <ol> and </ol>
         '/<li[^>]*>(.*?)<\/li>/i', // <li> and </li>
         '/<li[^>]*>/i', // <li>
         '/<a [^>]*href="([^"]+)"[^>]*>(.*?)<\/a>/ie',
                                                  // <a href="">
         '/<hr[^>]*>/i', // <hr>
         '/(<table[^>]*>|<\/table>)/i', // <table> and
</table>
         '/(<tr[^>]*>|<\/tr>)/i', // <tr> and </tr>
         '/<td[^>]*>(.*?)<\/td>/i', // <td> and </td>
         '/<th[^>]*>(.*?)<\/th>/ie', // <th> and </th>
         '/&(nbsp|#160);/i', // Non-breaking space
         '/&(quot|rdquo|ldquo|#8220|#8221|#147|#148);/i',
                                                  // Double quotes
         '/&(apos|rsquo|lsquo|#8216|#8217);/i', // Single quotes
         '/&gt;/i', // Greater-than
         '/&lt;/i', // Less-than
         '/&(amp|#38);/i', // Ampersand
         '/&(copy|#169);/i', // Copyright
         '/&(trade|#8482|#153);/i', // Trademark
         '/&(reg|#174);/i', // Registered
         '/&(mdash|#151|#8212);/i', // mdash
         '/&(ndash|minus|#8211|#8722);/i', // ndash
         '/&(bull|#149|#8226);/i', // Bullet
         '/&(pound|#163);/i', // Pound sign
         '/&(euro|#8364);/i', // Euro sign
         '/&[^&;]+;/i', // Unknown/unhandled
entities
         '/[ ]{2,}/' // Runs of spaces,
post-handling
     );

$mire = array(
         '', // Non-legal carriage
return
         ' ', // Newlines and tabs
         ' ', // Runs of spaces,
pre-handling
         '', // <script>s -- which
strip_tags supposedly has problems with
         '', // <style>s -- which
strip_tags supposedly has problems with
         "strtoupper(\"\n\n\\1\n\n\")", // H1 - H3
         "ucwords(\"\n\n\\1\n\n\")", // H4 - H6
         "\n\n\t", // <P>
         "\n", // <br>
         '_\\1_', // <b>
         '_\\1_', // <strong>
         '_\\1_', // <i>
         '_\\1_', // <em>
         "\n\n", // <ul> and </ul>
         "\n\n", // <ol> and </ol>
         "\t* \\1\n", // <li> and </li>
         "\n\t* ", // <li>
         '$this->_build_link_list("\\1", "\\2")',
                                                 // <a href="">
         "\n-------------------------\n", // <hr>
         "\n\n", // <table> and </table>
         "\n", // <tr> and </tr>
         "\t\t\\1\n", // <td> and </td>
         "strtoupper(\"\t\t\\1\n\")", // <th> and </th>
         ' ', // Non-breaking space
         '"', // Double quotes
         "'", // Single quotes
         '>',
         '<',
         '&',
         '(c)',
         '(tm)',
         '(R)',
         '--',
         '-',
         '*',
         '£',
         'EUR', // Euro sign. € ?
         '', // Unknown/unhandled
entities
         ' ' // Runs of spaces,
post-handling
     );

$dokumentum = <<<EOF
<p>zoltan.<strong>nemethmoveonerelo.com</strong></p><p><strong>zoltan.n<em>emethmov</em></strong><em>eonerelo.com</em></p><p><em>zoltan.nemethmov</em>eonerelo.com</p><p>zoltan.nemethmoveonerelo.com&nbsp;</p>
EOF;

$szoveg = preg_replace ($mit, $mire, $dokumentum);
echo $szoveg;

?>

And it throws the following error:

Parse error: syntax error, unexpected ''
in /home/znemeth/public_html/test/pregreplacetest1.php(94) : regexp code
on line 1

Fatal error: preg_replace() [<a
href='function.preg-replace'>function.preg-replace</a>]: Failed
evaluating code: _nemethmoveonerelo.com_
in /home/znemeth/public_html/test/pregreplacetest1.php on line 94

it appears both on
PHP Version 4.4.7-0.dotdeb.0
and
PHP Version 5.2.4-0.dotdeb.0

does anybody know what's this? why can a '' in the subject text cause
any problems?

any help greatly appreciated

thanks in advance
Zoltán Németh

attached mail follows:


On 10/29/07, Zoltán Németh <znemethalterationx.hu> wrote:
> hi list,
>
> I have this code:
[snip!]
> Parse error: syntax error, unexpected ''
> in /home/znemeth/public_html/test/pregreplacetest1.php(94) : regexp code
> on line 1
>
> Fatal error: preg_replace() [<a
> href='function.preg-replace'>function.preg-replace</a>]: Failed
> evaluating code: _nemethmoveonerelo.com_
> in /home/znemeth/public_html/test/pregreplacetest1.php on line 94
[snip=again!]

    Zoltan,

    If you're using preg_replace(), where are your start and stop
characters for the pattern and subject?

    $szoveg = preg_replace('/'.$mit.'/','/'.$mire.'/',$dokumentum);

    You could otherwise try ereg_replace(); without the slashes, or do
an htmlentities($dokumentum);.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Give a man a fish, he'll eat for a day. Then you'll find out he was
allergic and is hospitalized. See? No good deed goes unpunished....

attached mail follows:


Daniel Brown wrote:
> On 10/29/07, Zoltán Németh <znemethalterationx.hu> wrote:
>> hi list,
>>
>> I have this code:
> [snip!]
>> Parse error: syntax error, unexpected ''
>> in /home/znemeth/public_html/test/pregreplacetest1.php(94) : regexp code
>> on line 1
>>
>> Fatal error: preg_replace() [<a
>> href='function.preg-replace'>function.preg-replace</a>]: Failed
>> evaluating code: _nemethmoveonerelo.com_
>> in /home/znemeth/public_html/test/pregreplacetest1.php on line 94
> [snip=again!]
>
> Zoltan,
>
> If you're using preg_replace(), where are your start and stop
> characters for the pattern and subject?
>
> $szoveg = preg_replace('/'.$mit.'/','/'.$mire.'/',$dokumentum);
>
> You could otherwise try ereg_replace(); without the slashes, or do
> an htmlentities($dokumentum);.
>

Look again and you will notice that $mit and $mire are both arrays.

Also, the starting and stopping points are in the $mit array elements.

The starting and stopping points are not allowed in the $mire array.

This was the offending line in the code. I removed the e from the modifiers list and it started
working. See if you can run the code without it.

          '/<strong[^>]*>(.*?)<\/strong>/i', // <strong>

you missed your closing option
          '/<\/?p[^>]*>/i', // <P>

or maybe you should have a different entry to remove the </p> and replace it with nothing.
this
          '/<p[^>]*>/i', // <P>
that
         "\n\n\t",

this
          '/<\/p[^>]*>/i', // </P>
that
         '',

Side note, you might want to look into using the '+' instead of the '*'.
        '+' = must be one or more
        '*' = 0 or more

In some of the cases here, I see where this can bite you in the butt later.

--
Jim Lucas

    "Some men are born to greatness, some achieve greatness,
        and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
     by William Shakespeare

attached mail follows:


Børge Holen wrote:
> On Sunday 28 October 2007 07:27:53 you wrote:
>> Børge Holen wrote:
>>> I found this code at php.net witch needs very little modifications and
>>> can do so much, but I can't figure out how to make it read alphabeticly
>>> as mentioned
>>>
>>> $it = new RecursiveDirectoryIterator($_GET['location']);
>>> foreach (new RecursiveIteratorIterator($it, 2) as $path){
>>> if($path->isDir()){
>>> // writing to some static file
>>> }elseif(some unfinished statement){
>>> fwrite($dynfile, "$path\n");
>>> }else{
>>> // writing to some static file
>>> }
>>> }
>>>
>>> I just... nothings keeping me from sorting the the dynfile after writing,
>>> but also that seems to do the job twice instead of doing it correct the
>>> first time.
>>>
>>>> -nathan
>> I am trying to figure out what you are trying to do here.
>
> The code is for recursiving directory structure.
> Starting at a given location
>
>
>

Ok, so, let me get this straight.

You want the ability to display alphabetically, the files/directories of a given directory and all
sub-directories?

Now, do you want this echo'ed to the screen, or saved in a file like you did in your earlier example?

either way, the following code will help you I think.

<?php

function displayDirectory($path) {
        $data = glob($path.'/*');
        foreach ( $data AS $entry ) {
                if ( in_array($entry, array('./', '../')) ) {
                        continue;
                }
                if ( is_dir($entry) ) {
                        displayDirectory($entry);
                } else {
                        echo "{$entry}\n";
                }
        }
}

displayDirectory($_GET['location']);

--
Jim Lucas

    "Some men are born to greatness, some achieve greatness,
        and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
     by William Shakespeare