Category: PHP

Multi-dimensional Array sort by value in php

Suppose we have a array like

Array
(
    [0] => Array
        (
            [color] => Green
            [order] => 13
        )

    [1] => Array
        (
            [color] => Black
            [order] => 2
        )

    [2] => Array
        (
            [color] => White
            [order] => 10
        )
)

This type of array sort by value easily using following algorithm.

For ascending :

function asc_sort (&$array, $key) {
    $sorter = array();
    $ret = array();
    reset($array);
    foreach ($array as $ii => $va) {
        $sorter[$ii] = $va[$key];
    }
    asort($sorter);
    foreach ($sorter as $ii => $va) {
        $ret[$ii] = $array[$ii];
    }
    $array = $ret;
}
asc_sort($a_array, "color");

For descending :

function desc_sort (&$array, $key) {
    $sorter = array();
    $ret = array();
    reset($array);
    foreach ($array as $ii => $va) {
        $sorter[$ii] = $va[$key];
    }
    arsort($sorter);
    foreach ($sorter as $ii => $va) {
        $ret[$ii] = $array[$ii];
    }
    $array = $ret;
}

desc_sort($a_array, "color");

How to integrate joomla 1.5.x into wordpress

You should install WordPress first.

Now put joomla inside wordpress(wordpress/joomla ).

Now install joomla into same database that are already install wordpress.

All of the header and footer stuff in joomla is used from wordpress so you do not need to restyle it in joomla . All you need to do is to style and work on the content area of the joomla template output. Continue reading “How to integrate joomla 1.5.x into wordpress”