|
|
|
php - จัดเรียง array แบบ 2 มิติหน่อยครับ ทำแบบมิติเดียวได้แล้วครับ |
|
|
|
|
|
|
|
Code (PHP)
<?php
$multiArray = Array(
Array("id" => 1, "name" => "Defg"),
Array("id" => 2, "name" => "Abcd"),
Array("id" => 3, "name" => "Bcde"),
Array("id" => 4, "name" => "Cdef"));
$tmp = Array();
foreach($multiArray as &$ma)
$tmp[] = &$ma["name"];
array_multisort($tmp, $multiArray);
foreach($multiArray as &$ma)
echo $ma["name"]."<br/>";
/* Outputs
Abcd
Bcde
Cdef
Defg
*/
?>
|
|
|
|
|
Date :
2013-09-25 14:02:47 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
// string
$Family = array ( "Somchay" => array ( "Father" => "Pichai","Mom" => "Suvimon"),
"Nipon" => array ( "Father" => "Pichai","Mom" => "Suvimon"));
echo $Family['Somchay']['Father']; // == Pichi
?>
|
|
|
|
|
Date :
2013-09-25 14:08:11 |
By :
Ex-[S]i[L]e[N]t |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|