php将阿拉伯语与英语字符分开

in this question : php separate chinese from english characters separate chinese from english, but not work for arabic characters and not separated, how change that code to work for arabic characters ?

sample code for separate chinese from english characters :

$str = 'Hello 你怎么样? How are you?';

$english = preg_replace(array('/[\p{Han}?]/u', '/(\s)+/'), array('', '$1'), $str);
$chinese = preg_replace(array('/[^\p{Han}?]/u', '/(\s)+/'), array('', '$1'), $str);

echo $english . "
" . $chinese;

For your case you can use like,

$arabic = preg_replace(array('/[\x{0600}-\x{06FF}?]/u', '/(\s)+/'), array('', '$1'), $str);

Use the following regex to get the arabic and replace it

^[\u0621-\u064A\u0660-\u0669 ]+$