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

Home » Imported messages » comp.lang.php » randomly sorting files in php
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
getting perl and php to talk to each other, was Re: randomly sorting files in php [message #180596 is a reply to message #180590] Tue, 05 March 2013 09:19 Go to previous messageGo to previous message
Cal Dershowitz is currently offline  Cal Dershowitz
Messages: 36
Registered: February 2013
Karma:
Member
[x-posted to clp.misc]

On 03/03/2013 06:59 PM, Cal Dershowitz wrote:

> On 02/28/2013 10:54 PM, David Robley wrote:
>
>> Have a look at these functions for starters:
>>
>> rand()
>> array_rand()
>> shuffle()
>>
>
> Alright, David, I'm pleased with how far I've gotten with this so far
>
> $ pwd
> /var/www
> $ ls
> CCE0-705F index.html read_dir1.php read_dir3.php read_dir5.php
> date.php music1 read_dir1.php~ read_dir3.php~ read_dir5.php~
> date.php~ music1.sh read_dir2.php read_dir4.php test.php
> hello.php music1.sh~ read_dir2.php~ read_dir4.php~ Untitled Document
> $ cat read_dir4.php
> <?php
>
> function getFilesFromDir($dir) {
>
> $files = array();
> if ($handle = opendir($dir)) {
> while (false !== ($file = readdir($handle))) {
> if ($file != "." && $file != "..") {
> if(is_dir($dir.'/'.$file)) {
> $dir2 = $dir.'/'.$file;
> $files[] = getFilesFromDir($dir2);
> }
> else {
> $files[] = $dir.'/'.$file;
> }
> }
> }
> closedir($handle);
> }
>
> return array_flat($files);
> }
>
> function array_flat($array) {
>
> foreach($array as $a) {
> if(is_array($a)) {
> $tmp = array_merge($tmp, array_flat($a));
> }
> else {
> $tmp[] = $a;
> }
> }
>
> return $tmp;
> }
>
> // Usage
> $dir = 'music1';
> $foo = getFilesFromDir($dir);
>
> print_r($foo);
> ?>
> $
>
> This is my fourth version of this script, obviously written primarily by
> someone with more experience.
>
> The output is tremendous, and the next step is to use a regex to knock
> off leading numbers and underscores. I have a simple question.
>
> Given that you have the data in an array that is instantiated like this,
> how does one use best php form to use a regex on the whole thing?

This article has me convinced that I want perl and php able to deal with
each other:

http://www.linuxjournal.com/article/9282?page=0,1

The install didn't succumb to my first try, nor the second, which was this:

cpan[1]> install PHP::Interpreter
Going to read '/home/fred/.cpan/Metadata'
Database was generated on Mon, 28 Jan 2013 12:06:54 GMT
Fetching with LWP:
http://cpan.cs.utah.edu/authors/01mailrc.txt.gz
....

so far so good, and then this thing which I've seen in the literature:

using php_config 'php-config'
Can't exec "php-config": No such file or directory at Makefile.PL line 55.
Failed to find the 'php-config' executable. Make sure you have PHP and
PHP sources installed, and that 'php-config' is in PATH. at Makefile.PL
line 55.
....

bla bla bla do not pass Go. Right now I have a default installation.

Simple question: What types of things can I get configured with
php-config? envelope data available? ftp data?
--
Cal
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to avoid the use of session variables in this script
Next Topic: all done
Goto Forum:
  

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

Current Time: Thu Nov 28 14:59:09 GMT 2024

Total time taken to generate the page: 0.04164 seconds