/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Is There RTL Chars * Check if there RTL characters (Arabic, Persian, Hebrew) * * @author Khaled Attia (http://twitter.com/khal3d) * @param String $string * @return bool */ function is_there_rtl_chars( $string = '' ) { $rtl_chars_pattern = '/[\x{0590}-\x{05ff}\x{0600}-\x{06ff}]/u'; } // Arabic Or Persian $string = 'نص عربي أو Ùارسي'; if( is_there_rtl_chars( $string ) ) { echo "TRUE\n"; } // Hebrew $string = 'חופש למען פלסטין'; if( is_there_rtl_chars( $string ) ) { echo "TRUE\n"; } // Latin $string = 'English'; if( ! is_there_rtl_chars( $string ) ) { echo "FALSE\n"; }
URL: http://twitter.com/Khal3d/status/52076070178013185