473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Array Sorting issue--php

268 100+
Hai friends
I need to sort the array values.

Array value is
Array ( [160x600] => Array ( [0] => 21 [1] => 1 [2] => 0 [3] => 0 ) [300x250] => Array ( [0] => 32 [1] => 2 [2] => 0 [3] => 0 ) )


First I am using ksort to sort the array values.Now I neet to sort [0] => 21 and [0] => 32


How to sort Array in array ? Please send any suggestion

Thanks
__________________
Thanks
Vssp
Dec 28 '06 #1
1 1067
ronverdonk
4,258 Expert 4TB
[0] =>21 and [0] 32 are not arrays, so I assume you mean the sub-arrays. This sample sort the 300x250 sub-array.
[php]<?php
$arr=Array ('160x600' => Array ( 0 => 21, 1 => 1, 2 => 0, 3 => 0 ) ,
'300x250' => Array ( 0 => 32, 1 => 2, 2 => 0, 3 => 0 ) );
sort($arr['300x250']);
echo '<pre>'; print_r($arr);
?>[/php]
Result:
Expand|Select|Wrap|Line Numbers
  1. Array
  2. (
  3.     [160x600] => Array
  4.         (
  5.             [0] => 21
  6.             [1] => 1
  7.             [2] => 0
  8.             [3] => 0
  9.         )
  10.     [300x250] => Array
  11.         (
  12.             [0] => 0
  13.             [1] => 0
  14.             [2] => 2
  15.             [3] => 32
  16.         )
  17. )
  18.  
  19.  
Ronald :cool:
Dec 28 '06 #2

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

Similar topics

2
by: Alvaro G Vicario | last post by:
I have this test code: <html><pre><? echo "Versión: ".phpversion()."\n\n"; $define_list = array( 'PRODUCT_LIST_MODEL' => 0, 'PRODUCT_LIST_NAME' => 0,
13
by: dr. zoidberg | last post by:
Hello, I have mysql table: +----+---------+ | 1 | value1 | +----+---------+ | 2 | value2 | +----+---------+ | 3 | value3 |
5
by: trs | last post by:
thanks for reading this. problem: logical error is preventing array from sorting right code: #include <iostream> #include <cmath> using namespace std; struct coords { int x;
4
by: John Bullock | last post by:
Hello, I am at wit's end with an array sorting problem. I have a simple table-sorting function which must, at times, sort on columns that include entries with nothing but a space (@nbsp;). I...
6
by: bill | last post by:
I am about to start on a module that will accept a location from a user, use Google geolocation services to get the lat/lon and then compute the distance from the site visitor to about 100 kennels...
1
by: cronet | last post by:
Hi, i want to do some sortings to a complex array. The array structure is at the end of this message Now I want the result sorted in that way: SingleRoom ($hotel) - lowest rate ($hotel )
4
by: Ravi4raj | last post by:
Hi all, Here i have to know is thr any way to sort the array according to thr Bit Reverse.. for Example: If we take the Array size of 256,then the Sorting Should be like below. a =...
3
by: tevo | last post by:
Hello, I'm trying to do a Perl script on Windows (wish it was Unix) that goes to a directory, figures out which files are most recent, within the last week, then copies them to another dir. I'm...
1
by: Totti | last post by:
Hi everyone, I am a newbie to javascript learning it for 2 months now, i am trying to make a sorter who will read english words from the one textbox or datafile and store them in a 2 dimensional...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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
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...

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.