The PHP code is as follows:
1 2/**
3 * Inverted two-dimensional array inserts an element
4 *
5 * @author Wadeyu
6 * @date 2012-05-30
7 */
8 $aSorted = Array (
9 Array (1, 100),
Ten Array (2, 90),
Array (3, 80),
Array (4, 70),
Array (5, 60),
Array (6, 50),
Array (7, 40),
Array (8, 40),
Array (9, 40),
Array (10, 20),
19);
$aInsert = Array (11, 40);
$MAXCMPIDX = 0;
$cnt = 0;
$maxCnt = 10;
($aSorted as $idx = + $arr) {
if ($arr [0] = = $aInsert [0]) {
$MAXCMPIDX = $idx;
27}
$cnt + +;
29}
if (! $maxCmpIdx) {
$MAXCMPIDX = $cnt + +;
32}
$aSorted [$MAXCMPIDX] = $aInsert;
for ($i = $MAXCMPIDX; $i > 0; $i--) {
if ($aSorted [$i][1] > $aSorted [$i -1][1]) {
$ATMP = $aSorted [$i-1];
PNS $aSorted [$i-1] = $aSorted [$i];
$aSorted [$i] = $ATMP;
Continue;
40}
a break;
42}
($i = $cnt; $i > $maxCnt; $i-) {
Unset ($aSorted [$i-1]);
45}
Print_r ($aSorted);
Excerpt from Huan & Ping
http://www.bkjia.com/PHPjc/478176.html www.bkjia.com true http://www.bkjia.com/PHPjc/478176.html techarticle The PHP code is as follows: 1? PHP 2/** 3 * Reverse two-dimensional array insert an element 4 * 5 * @author Wadeyu 6 * @date 2012-05-30 7 */8 $aSorted = Array (9 array (1, (2, +), Array ( ...).