Hi there,
I want to scan a dir, put the *.gif into an array, and order that (
01.gif, 02.gif etc),
and put that array into a $_session-array. (Session & Headers are
initiated before this code)
I have the code below, everything works, except for the ordering.
Any clues ?
Thanks, Frizzle.
$dir = opendir("./img/");
while( $file = readdir($dir)){
if (preg_match("/\.gif$/", $file)) {
$filename = preg_replace( "/\.gif$/", '', $file );
$_SESSION['all_pics'][$filename] = "Foobar";
};
};
closedir( $dir );
asort( $_SESSION['all_pics'] ); 5 1082
frizzle wrote:
Hi there,
I want to scan a dir, put the *.gif into an array, and order that (
01.gif, 02.gif etc),
and put that array into a $_session-array. (Session & Headers are
initiated before this code)
I have the code below, everything works, except for the ordering.
Any clues ?
$_SESSION['all_pics'][$filename] = "Foobar";
asort( $_SESSION['all_pics'] );
Well, if the value of every array item is the same, offcourse there will be
no sorting done.
If you want to sort on key:
ksort($_SESSION['all_pics']);
Allthough I can't image why:
$_SESSION['all_pics'][] = $filename;
...
asort($_SESSION['all_pics']);
does not do...
--
Rik Wasmus
On 25 Oct 2006 11:06:14 -0700, "frizzle" <ph********@gmail.comwrote:
>I want to scan a dir, put the *.gif into an array, and order that ( 01.gif, 02.gif etc), and put that array into a $_session-array. (Session & Headers are initiated before this code) I have the code below, everything works, except for the ordering.
$filename = preg_replace( "/\.gif$/", '', $file ); $_SESSION['all_pics'][$filename] = "Foobar";
asort( $_SESSION['all_pics'] );
All the values in your array are equal to "Foobar", and so asort doesn't need
to do anything to the array to sort it.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Andy Hassall wrote:
On 25 Oct 2006 11:06:14 -0700, "frizzle" <ph********@gmail.comwrote:
I want to scan a dir, put the *.gif into an array, and order that (
01.gif, 02.gif etc),
and put that array into a $_session-array. (Session & Headers are
initiated before this code)
I have the code below, everything works, except for the ordering.
$filename = preg_replace( "/\.gif$/", '', $file );
$_SESSION['all_pics'][$filename] = "Foobar";
asort( $_SESSION['all_pics'] );
All the values in your array are equal to "Foobar", and so asort doesn't need
to do anything to the array to sort it.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
I'm sorry, i guess i wasn't clear.
I want it ordered by it's keys ...
$_SESSION['all_pics'][$filename]
---------------------------------------^
Thanks for the fast reply.
Frizzle.
On 25 Oct 2006 11:29:15 -0700, "frizzle" <ph********@gmail.comwrote:
>Andy Hassall wrote:
>On 25 Oct 2006 11:06:14 -0700, "frizzle" <ph********@gmail.comwrote:
>>>I want to scan a dir, put the *.gif into an array, and order that ( 01.gif, 02.gif etc), and put that array into a $_session-array. (Session & Headers are initiated before this code) I have the code below, everything works, except for the ordering.
$filename = preg_replace( "/\.gif$/", '', $file ); $_SESSION['all_pics'][$filename] = "Foobar";
asort( $_SESSION['all_pics'] );
All the values in your array are equal to "Foobar", and so asort doesn't need to do anything to the array to sort it.
I'm sorry, i guess i wasn't clear. I want it ordered by it's keys ...
$_SESSION['all_pics'][$filename]
Start at http://uk2.php.net/manual/en/ref.array.php
Look at all the various functions with "sort" in their name. You'll find the
one you want soon enough.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Andy Hassall wrote:
On 25 Oct 2006 11:29:15 -0700, "frizzle" <ph********@gmail.comwrote:
Andy Hassall wrote:
On 25 Oct 2006 11:06:14 -0700, "frizzle" <ph********@gmail.comwrote:
I want to scan a dir, put the *.gif into an array, and order that ( 01.gif, 02.gif etc), and put that array into a $_session-array. (Session & Headers are initiated before this code) I have the code below, everything works, except for the ordering.
$filename = preg_replace( "/\.gif$/", '', $file ); $_SESSION['all_pics'][$filename] = "Foobar";
asort( $_SESSION['all_pics'] );
All the values in your array are equal to "Foobar", and so asort doesn't need
to do anything to the array to sort it.
I'm sorry, i guess i wasn't clear.
I want it ordered by it's keys ...
$_SESSION['all_pics'][$filename]
Start at http://uk2.php.net/manual/en/ref.array.php
Look at all the various functions with "sort" in their name. You'll find the
one you want soon enough.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Great! Ksort. Can't believe i missed that.
Thanks again.
Frizzle. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ken Fine |
last post by:
(originally posted to one of macromedia's groups; no help, so hopefully
someone here can help me out. I'm using VBScript ASP.)
When designing administrative interfaces to websites, we often need...
|
by: Fabian |
last post by:
With teh following code, if I put picnames first, it wont work because
the other variables havent yet been defined, correct? That seems to be
the case. What I want to know is whether that is a...
|
by: jr |
last post by:
Sorry for this very dumb question, but I've clearly got a long way to go!
Can someone please help me pass an array into a function. Here's a starting
point.
void TheMainFunc()
{
// Body of...
|
by: Brendan.Collins |
last post by:
Hi
I have a javascript problem that has been annoying me for two days now
and thought that a javascript expert might have the magic solution.
I am populating a table dynamically from the...
|
by: srikant |
last post by:
I am writing a client in C# that needs to communicate over the network to a legacy C++ application that uses Unicode strings. I realize that C# strings are already in Unicode, however, how do I...
| |
by: Benjamin M. Stocks |
last post by:
Hello all,
I've heard differing opinions on this and would like a definitive
answer on this once and for all. If I have an array of 4 1-byte values
where index 0 is the least signficant byte of a...
|
by: subramanian |
last post by:
Hello
I have a doubt in the following piece of code:
int a;
printf("a=%p\n", a);
printf("&a=%p\n", &a);
these printf statements print the same value for both 'a' and '&a".
I tried in...
|
by: DarelRex |
last post by:
Is it possible to pass a 2-D, statically defined array?
Here's a 1-D example that won't work:
void foo() {
int myArray ;
bar(myArray);
}
void bar(int *arr) {
|
by: Mr.SpOOn |
last post by:
Hi,
I need a structure to represent a set of integers. I also need to
perform on this set some basic set operations, such as adding or
removing elements, joining with other sets and checking for...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |