santanudas
Technical User
Hi all,
What would be the PHP equivalent of this Perl construct:
all it's doing is filing in the array (i.e. @images) with values from “ls” command and then finding the position (i.e. $position) of a given file (i.e. some_file.jpg) in that array. How to rewrite that in PHP? Sorry if it's dumb questions and too easy to do in PHP but it'd be a great help for me if someone can show show me how to. Thanks in advance for your time helping me.
What would be the PHP equivalent of this Perl construct:
Code:
$ENV{"PATH"} = "/bin:/usr/bin";
my $ls = `/bin/ls /path/to/dir/some_dir/`;
my @images = split /\n/, $ls;
my $name = "some_file.jpg";
my ($position, %pics);
$pics{$images[$_]} = $_ for 0 .. $#images;
$position = $pics{ $name };