php-general Digest 28 Oct 2007 19:29:31 -0000 Issue 5097
Topics (messages 263756 through 263765):
Re: SPL
263756 by: Børge Holen
263757 by: Børge Holen
263760 by: Nathan Nobbe
263765 by: Børge Holen
Newline
263758 by: magoo
263761 by: Nathan Nobbe
using `php' in the name of software
263759 by: Andrew O. Shadoura
263762 by: Jochem Maas
263763 by: Andrew O. Shadoura
263764 by: Jochem Maas
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
On Sunday 28 October 2007 02:57:13 Jochem Maas wrote:
> Børge Holen wrote:
> > On Sunday 28 October 2007 01:32:15 you wrote:
> >> On 10/27/07, Børge Holen <[EMAIL PROTECTED]> wrote:
> >>> I'm currently using RecursiveDirectoryIterator and
> >>> RecursiveIteratorIterator.
> >>> I'm using fwrite to write to a file while parsing throught the file
> >>> structure,
> >>> and was wondering if it is at all possible to sort alphabetical without
> >>> going
> >>> all array. That seems to me like doing the job twice over. Atleast part
> >>> of it...
> >>
> >> how are you doing the sorting part?
> >> can you show us some of your code ?
> >
> > thats the problem, i don't know how to sort before read starts, that came
> > out a bit wrong. I need to read the filesystem alphabeticly.
> >
> > I could use the system command 'find somepath' and then use '| sort'
> > witch was part of my old stuff with a ton of waste code.
> > or I could 'sort array' witch of course forces me to create an array to
> > loop around and push at each folder and leaf.
> >
> > 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']);
>
> ^-- you modified this
> part right?
yes I did, it is wrong all together and is supposed to be like this
$it = new RecursiveDirectoryIterator('/store'.$_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.
>
> you have a file stream open, I have no idea what a $path->__toString()
> results in but I'll assume it's the full path.
Yes it will only show me the folder structure, ie. no files. Here I have some
unfinished string work to do, but in each of those if elseif and else I want
to sort.
> whats to stop you seeking in
> the file and using string comparison to find the correct position (ie.
> line) to inject a path.
Here I wrote a lot of execuse why I didn't do that, I changed my mind after 10
lines, I love that Idea, I just thought like make an appendix for each
append. This is not probably what you was thinking of, but I'm going to use
that one. Thats for appending though, what about each time I write a new
file, and the file is empty.
Searching for position here probably isn't the best solution since the fastest
method is just to start read it right.
> so basically sort as you write into the file, how to do this efficiently
> is another question. :-)
fwrite($dynfile, "$path\n");
this works satisfyingly, short pretty 1line. BUT I'm always in for suggestions
>
> >> -nathan
--
---
Børge Holen
http://www.arivene.net
--- End Message ---
--- Begin Message ---
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
--
---
Børge Holen
http://www.arivene.net
--- End Message ---
--- Begin Message ---
i suppose this is what youre looking for ?
you can tailor it to your needs of course :)
<?php
$it = new RecursiveDirectoryIterator('.');
$isFirstDir = true;
$fileList = array();
$dynfile = fopen('sortedFiles', 'w+');
$theRecursiveIteratorIterator =
new RecursiveIteratorIterator($it,
RecursiveIteratorIterator::CHILD_FIRST);
foreach ($theRecursiveIteratorIterator as $path){
if($path->isDir()){
/// drop the name of the directory into the results
fwrite($dynfile, 'Directory: ' . (string) $path . PHP_EOL);
if($isFirstDir) { // just update the flag on the first
dir
$isFirstDir = false;
} else {
sort($fileList); // sort the list however you
like
/// iterate over the sorted list, placing them in
the output file
foreach($fileList as $sortedDirFile) {
fwrite($dynfile, $sortedDirFile . PHP_EOL);
}
$fileList = array(); // clear the list for the
next directory
}
}else{ /// place the current path to a file in the list
$fileList[] = (string) $path;
}
}
fclose($dynfile);
?>
-nathan
--- End Message ---
--- Begin Message ---
On Sunday 28 October 2007 15:37:21 Nathan Nobbe wrote:
> i suppose this is what youre looking for ?
> you can tailor it to your needs of course :)
>
> <?php
> $it = new RecursiveDirectoryIterator('.');
> $isFirstDir = true;
> $fileList = array();
> $dynfile = fopen('sortedFiles', 'w+');
> $theRecursiveIteratorIterator =
> new RecursiveIteratorIterator($it,
> RecursiveIteratorIterator::CHILD_FIRST);
>
> foreach ($theRecursiveIteratorIterator as $path){
> if($path->isDir()){
> /// drop the name of the directory into the results
> fwrite($dynfile, 'Directory: ' . (string) $path . PHP_EOL);
> if($isFirstDir) { // just update the flag on the
> first dir
> $isFirstDir = false;
> } else {
> sort($fileList); // sort the list however
> you like
> /// iterate over the sorted list, placing them in
> the output file
> foreach($fileList as $sortedDirFile) {
> fwrite($dynfile, $sortedDirFile . PHP_EOL);
> }
> $fileList = array(); // clear the list for the
> next directory
> }
> }else{ /// place the current path to a file in the list
> $fileList[] = (string) $path;
> }
> }
> fclose($dynfile);
> ?>
>
>
> -nathan
both yes and no.
Yes I can modify this 'n put it to good use, and no I'm stille buggered with
creating array just to print it again, when I could've writting it instead of
filling the array.
--
---
Børge Holen
http://www.arivene.net
--- End Message ---
--- Begin Message ---
Hi NG!
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";.
What`s the best way to get a consitent code?
--
Kind regards,
magoo
--- End Message ---
--- Begin Message ---
On 10/28/07, magoo <[EMAIL PROTECTED]> wrote:
>
> Hi NG!
>
> 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";.
> What`s the best way to get a consitent code?
>
choose the string syntax that best fits the purpose of the given string.
if a string will not have variables embedded in it, or special characters,
use
single quotes. if it will, use double quotes.
if you have a particularly long string, with variables and special
characters
consider Heredoc.
-nathan
--- End Message ---
--- Begin Message ---
Hello.
I'm developing an extension for PHP to support netCDF format (a special format
for multidimensional scientific data). It is non-commercial open source
project. At http://www.php.net/license/3_01.txt it is said that I cannot name
my extension php-netcdf unless you permit. So, I'm asking you for this,
because I want my extension (in future) to be included in standard set of
extensions.
P.S. Under term `extension' I mean binary .so/.dll extension (particularly,
written in C) that was written using ext-skeleton output and that uses php
includes/libraries and is distributed under terms of PHP license because of
that.
--
WBR, Andrew
--- End Message ---
--- Begin Message ---
Andrew O. Shadoura wrote:
> Hello.
>
> I'm developing an extension for PHP to support netCDF format (a special
> format
> for multidimensional scientific data). It is non-commercial open source
> project. At http://www.php.net/license/3_01.txt it is said that I cannot name
> my extension php-netcdf unless you permit. So, I'm asking you for this,
> because I want my extension (in future) to be included in standard set of
> extensions.
>
> P.S. Under term `extension' I mean binary .so/.dll extension (particularly,
> written in C) that was written using ext-skeleton output and that uses php
> includes/libraries and is distributed under terms of PHP license because of
> that.
you should ask this on [EMAIL PROTECTED] but if you ask me you should just
call the extension netcdf e.g. it's full name would be "the php netcdf
extension".
the 'php-' is superfluous no?
>
--- End Message ---
--- Begin Message ---
Hello.
Jochem Maas wrote:
> you should ask this on [EMAIL PROTECTED] but if you ask me you
> should just call the extension netcdf e.g. it's full name would be "the
> php netcdf extension". the 'php-' is superfluous no?
The extension itself named `netcdf', but a package name, svn project name,
and so on? For example, if I want to make a Debian package (or even just
source tarball), can I name it php-netcdf.deb/php-netcdf.tar.gz/etc?
--
WBR, Andrew
--- End Message ---
--- Begin Message ---
Andrew O. Shadoura wrote:
> Hello.
>
> Jochem Maas wrote:
>
>> you should ask this on [EMAIL PROTECTED] but if you ask me you
>> should just call the extension netcdf e.g. it's full name would be "the
>> php netcdf extension". the 'php-' is superfluous no?
>
> The extension itself named `netcdf', but a package name, svn project name,
> and so on? For example, if I want to make a Debian package (or even just
> source tarball), can I name it php-netcdf.deb/php-netcdf.tar.gz/etc?
I don't see why that could be a problem - your merely indicating what it is,
besides extensions like curl do the same.
maybe double check with the php group ask the guys on [EMAIL PROTECTED]
but Im pretty sure you won't find any objections :-)
>
--- End Message ---