Q:

how can i sort 2 dimensional array based on index array in PHP? 

I have an array in PHP like this :
Array
(
    [0] => Array
        (
            [0] => black
            [2] => brown
            [1] => red
        )
[1] => Array
    (
        [2] => car
        [0] => bicycle
        [1] => motorcycle
    )

)
How do I get the array, like this :
Result:
Array
(
    [0] => Array
        (
            [0] => black
            [1] => red
            [2] => brown
        )
[1] => Array
    (

        [0] => bicycle
        [1] => motorcycle
        [2] => car
    )

)
Thanks

A:

You could try like this perhaps:
$arr=array(
    array(2=>'red',1=>'green',3=>'black'),
    array(1=>'pink',3=>'blue',2=>'yellow')
);
array_walk( $arr, function(&$v,$k){
    ksort($v);
});
echo '<pre>', print_r( $arr, true ), '</pre>';

Outputs:
Array
(
    [0] => Array
        (
            [1] => green
            [2] => red
            [3] => black
        )

    [1] => Array
        (
            [1] => pink
            [2] => yellow
            [3] => blue
        )

)

