2

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.

enter image description here

and second with RTL data display.

enter image description here

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.

j0k
  • 22,600
  • 28
  • 79
  • 90
Dipesh Parmar
  • 27,090
  • 8
  • 61
  • 90

1 Answers1

0

I'm not sure about how you do support right to left on your site, and I can't comment yet to ask you some clarification (it would be useful some html output in addittion to the screenshots), so I'm trying to guess.

Your second screenshot doesn't show the order you said, in my opinion. Looking closer at contents between brackets, the RTL order result appears to be the same than before -book 5, first line-, reading from left to right, but with 32 ( pushed to the right and inverted so that it looks like ) 32. Something similar on the second line: the ). from the right side pushed to the left as .(.

I don't understand how it was messed up like that, but it doesn't seem to be a sorting problem, but a matter of layout related to the RTL displaying. I would check if the output from PHP is the expected by the html with RTL option.

Rober
  • 76
  • 1
  • 8