Jump to content

[SOLVED] ksort doesn't sort right.


Lumio

Recommended Posts

Hello... I start with an array like that:

Array
(
    [iNBOX] => Array
        (
            [Drafts] => Array()
            [hello world] => Array
                (
                    [test] => Array
                        (
                            [lala] => Array()
                            [alo] => Array()
                            [me] => Array()
                        )
                    [lala] => Array()
                )
            [sent] => Array()
            [Trash] => Array()
        )
)

Now I want to sort them all. I made a function that doese... nearly...

<?php //classname: qMail
	private function sortFolders($array) {
		ksort($array);
		echo '<pre>';
		print_r($array);
		'</pre>';
		foreach ($array as $i => $a)
			$array[$i] = $this->sortFolders($a);
		return $array;
	}
?>

Now it turns out the following array:

Array
(
    [iNBOX] => Array
        (
            [Drafts] => Array()
            [sent] => Array()
            [Trash] => Array()
            [hello world] => Array
                (
                    [lala] => Array()
                    [test] => Array
                        (
                            [alo] => Array()
                            [lala] => Array()
                            [me] => Array()
                        )
                )
        )
)

But "hello world" should be the second one.

 

//edit:

I see... it is case-sensitive too.

Link to comment
https://forums.phpfreaks.com/topic/86839-solved-ksort-doesnt-sort-right/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.