I am having a strange problem while developing a site in PHP with Right-To-Left support.
Take a look at these two screenshots below.
First with normal output.
and second with RTL data display.
As you see, the data is not displayed by order of page number.
In normal output the numbers are displaying 32, then 43, followed by 67, 88, and 325. In Right-To-Left output however, the numbers display out of their ascending order. Instead they output: first 32, then 88, 67, 43, etc.
For the above output (displayed in these screenshots) I have used the code below:
aasort($index['Book']['Index'],"page_number");
foreach($index['Book']['Index'] as $newIndex) :
$indLink = stripslashes($newIndex['content']);
$indPageNumberLink = $newIndex['page_number'];
$booksIndex .= " <span>". $indPageNumberLink ." (". $indLink ."). </span>";
endforeach;
echo "<dd class='bookindex_content'> ". rtrim($booksIndex,",") ."</dd></dl>";
And this is my aasort
function:
function aasort (&$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;
}
In short, this is the issue: the numbers are all output in ascending order except when I'm working in Right-To-Left.
What is the explanation for this? What am I doing wrong.