When i try to write a string in non english using php it gets written in the opposite direction, for example:
if i write: “example”, it’ll write “elpmaxe”
So i wanna build an php function which will correct the string to be “example”
Anyone can help me on this?
I’ve tried the following, but it didnt work.
Be careful with strrev though, as it may not support utf-8 characters. However, if you read the first few comments on the manual page listed above, there are UTF-8 compatible methods in the comments.
kduv
Another easy way would be to do something like the following – which I believe is UTF-8 safe:
Tested and its not UTF-8 safe
Anyways, I’ve encountered an issue with this, and that got it abit more complicated.
I noticed that numbers, special chars and english letters are all printed just fine, its only my language which is printed in a reversed order.
So im wondering, how can i modify the below function to not reverse english letters, numbers and symbols, and ofcourse keep the order of the sentence as original.
example:
su llac 01234567
should become:
call us 01234567
Its not related to RTL, in regular HTML files the text prints just fine.
I got the problem when i try to put some text as image using imagettftext such as in the following example:
imagefttext($template, 30, 0,0, 50, 0, 'gyadl.ttf', 'something'); // results in 'gnihtemos' being printed
Well, did you try the same thing but using a different font? Maybe the font is the cause of your problem?
I’m sorry if my idea seems silly to you, but I do not know any more about what would cause this issue if isolating this variable (the font) does not lead you any closer to fixing it.
Tried many different fonts, all are printed in reversed order.
It seems like i must reverse the string, but it also seems like that making numbers and symbols not messing it up is kinda hard.
So my final solution is going to be to remove all symbols & numbers from the string before reversing it.