473,468 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How does PHP order an array? Are numbers > letters or vice versa?

60 New Member
In an array, what's "bigger" ??

"aaaa1111" or "aaaa" or "1111" or "1111aaaa" OR 'aaaa1111' or 'aaaa' or '1111' or '1111aaaa'

Because i want to order an array, for example $arr = array('4wf', 'wf7u', '2345', '342gf', 'zzzzzzzzz', 'a', '999999999999', '1');
The biggest value here is '999999999999' ???

So, PHP orders NUMBERS first and then LETTERS ???
Jun 11 '07 #1
2 1598
pbmods
5,821 Recognized Expert Expert
Changed thread title to better describe the problem.

Try using sort and see what happens.

Alternatively, you could use usort to specify your own comparison function.
Jun 12 '07 #2
Motoma
3,237 Recognized Expert Specialist
In an array, what's "bigger" ??

"aaaa1111" or "aaaa" or "1111" or "1111aaaa" OR 'aaaa1111' or 'aaaa' or '1111' or '1111aaaa'

Because i want to order an array, for example $arr = array('4wf', 'wf7u', '2345', '342gf', 'zzzzzzzzz', 'a', '999999999999', '1');
The biggest value here is '999999999999' ???

So, PHP orders NUMBERS first and then LETTERS ???
You could use usort along with one of the strcmp...() functions to choose which way you want things sorted.
Jun 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Andrea | last post by:
Hi, I'm trying to emulate part of our client-server application as a web site so customers can use it, and I'm stuck when it comes to re-ordering items in a list. Basically we have a list of...
1
by: Wolfgang Keller | last post by:
Hello, just as an introduction: I'm not a developer by profession, I just need a solution for this within the scope of a single project... What I am looking for is basically a tool (usable for...
15
by: Eirik | last post by:
This is a little function I wrote, inspired by the thread "Urgent HELP! required for Caesar Cipher PLEASE" $ cat /home/keisar/bin/c/ymse/rot13.h char rot13(char character) { int changed;...
8
by: vijay | last post by:
Hello, As the subject suggests, I need to print the string in the reverse order. I made the following program: # include<stdio.h> struct llnode { char *info;
1
by: lifeshortlivitup | last post by:
I'm trying to write a program that will allow me to enter a number followed by a c or C and convert it to fahrenheit or vice versa but don't know how to do my variables. I have the following for the...
4
by: Andi | last post by:
Hi, I want to define the following functions before main(); I work with 2D arrays (fftw_complex) wich are arrays with array is real and array the imaginary part of a complex number. Now I want to...
1
by: Christian Schmidt | last post by:
Hi all, I need to implement an unmanaged function that gets a SafeArray and hands it over to a managed function having the managed array-type. Using MarshalAs I can call unmanaged functions having...
2
by: markszlazak | last post by:
I'm a relatively slow response of table cells changing their background color with mouseover/our in IE6 (Win 2K) but the response is fine (fast) in Firefox. Why? The code is below. Sorry about the...
7
by: victory2006 | last post by:
like we have an integer value of : 9 and i need to convert it to binary numbers and vice versa, thanks!
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.