R
E
S
O
U
R
C
E
S
       Home      Products & Services      Contact Us      Links


WebHatchers will design & develop your site for you.
_______________________

Website Menu Heaven: menus, buttons, etc.
_______________________

Send us your questions.
_______________________

site search by freefind
_______________________

HOME
SEO, Google, Privacy
   and Anonymity
Browser Insanity
JavaScript
Popups and Tooltips
Free Website Search
HTML Form Creator
Animation
Buttons and Menus
Counters
Captchas
Image Uploading
CSS and HTML
PHP
AJAX
XPATH
Website Poll
IM and Texting
Databases—MySQL
   or Not MySQL
Personal Status Boards
Content Management
   Systems
Article Content
   Management Systems
Website Directory
   CMS Systems
Photo Gallery CMS
Forum CMS
Blog CMS
Customer Records
   Management CMS
Address Book CMS
Private Messaging CMS
Chat Room CMS
JavaScript Charts
   and Graphs




Free Personal Status Boards (PSB™)

Free Standard Free PSB

Free PSB Pro Version

Free Social PSB

Free Social PSB Plus (with Email)

Free Business PSB

Free Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement



Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

PHP Using array_multisort

The PHP array_multisort function is very powerful. With it, you sort any number of arrays so that the first array sorts and is used as a template for the sorting of the other arrays. In the example below, when the array('6','7','3') sorts so that the 3 jumps to the first element position, the array('a','b','c') array does the same, with the c jumping to the front, parallel to what the 3 did, the 30 jumping to the front in array('10','20','30'), and the z jumping to the front in array('x','y','z'). The array_multisort($myArray, $myArray1, $myArray2, $myArray3); command does the job nicely.

This can come in very handy if you have put a bunch of records into arrays, with each field getting its own array. Then the sorting on one field results in a parallel sort happening in the other fields so that each record is still correct—assuming that all the element 0s of all the arrays still represent one single record, and all the element 1s of all the arrays still represent one single record, and so on.

THE PHP CODE GENERATES THE FOLLOWING DISPLAY:

PHP Using array_multisort
$myArray=array('6','7','3');
$myArray1=array('a','b','c');
$myArray2=array('10','20','30');
$myArray3=array('x','y','z');


6 7 3
a b c
10 20 30
x y z
before multisort


3 6 7
c a b
30 10 20
z x y
after multisort: all arrays sort like 1st array




THE PHP CODE:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>PHP Using array_multisort</TITLE>
<meta name="description" content="PHP Using array_multisort">
<meta name="keywords" content="PHP Using array_multisort,Using array_multisort,array_multisort,php,PHP,javascript, dhtml, DHTML">
</HEAD>
<body>
<h1 align=center>PHP Using array_multisort</h1>
<div style='font-size:24px;margin:0 0 0 300px'>

$myArray=array('6','7','3');<BR>
$myArray1=array('a','b','c');<BR>
$myArray2=array('10','20','30');<BR>
$myArray3=array('x','y','z');<BR><BR>

<?php

$myArray=array('6','7','3');
$myArray1=array('a','b','c');
$myArray2=array('10','20','30');
$myArray3=array('x','y','z');

echo $myArray[0]." ";
echo $myArray[1]." ";
echo $myArray[2]." ";
echo "<BR>";
echo $myArray1[0]." ";
echo $myArray1[1]." ";
echo $myArray1[2]." ";
echo "<BR>";
echo $myArray2[0]." ";
echo $myArray2[1]." ";
echo $myArray2[2]." ";
echo "<BR>";
echo $myArray3[0]." ";
echo $myArray3[1]." ";
echo $myArray3[2]." ";
echo "<BR>before multisort<BR><BR><BR>";

array_multisort($myArray, $myArray1, $myArray2, $myArray3);

echo $myArray[0]." ";
echo $myArray[1]." ";
echo $myArray[2]." ";
echo "<BR>";
echo $myArray1[0]." ";
echo $myArray1[1]." ";
echo $myArray1[2]." ";
echo "<BR>";
echo $myArray2[0]." ";
echo $myArray2[1]." ";
echo $myArray2[2]." ";
echo "<BR>";
echo $myArray3[0]." ";
echo $myArray3[1]." ";
echo $myArray3[2]." ";
echo "<BR>after multisort: all arrays sort like 1st array<BR>";
?>
</div>
</body>
</html>