Page 1 of 1

ksort krazyness

Posted: Wed Aug 10, 2005 4:44 am
by shiznatix
i have array that looks exactally like this

Code: Select all

Array
(
    [4] => Patch
    [5] => Report
    [12] => the
    [15] => of
    [17] => loss
    [6] => is
    [10] => deals
    [1] => Weight
    [13] => different
    [7] => a
    [0] => The
    [16] => weight
    [18] => patches,
    [19] => obviously.
    [2] => Loss
    [3] => Diet
    [14] => types
    [8] => report
    [9] => that
    [11] => with
)
then i run this code

Code: Select all

$ok = ksort($finish);
echo '<pre>';
print_r($ok);
echo '</pre>';
finish is the array above. when i print_r($ok) i get "1" thats it nothing else just the number 1. why?

EDIT: note, this is where $finish comes from

Code: Select all

$finish = $newlinesarr + $arrlines;

//so the whole part looks like
$finish = $newlinesarr + $arrlines;
echo '<pre>';
print_r($finish);
echo '</pre>';
$ok = ksort($finish);
echo '<pre>';
print_r($ok);
echo '</pre>';

Posted: Wed Aug 10, 2005 4:49 am
by patrikG
ksort returns 0 or 1 (false or true) depending on sorting success. Print your array instead for the sorting-results :)

Posted: Wed Aug 10, 2005 4:55 am
by shiznatix
silly rabbit, you cant assign a variable to a ksort!