Search code examples
persianfarsi

php remove arabic/farsi string from string


I got content from other website(persian language) by "simple dom html" and stored content of div to variable , here it is my code:

 $html = file_get_html('./test.html');
$tmp = $html->find('a div.min_price_space')->plaintext;

so my first question is how can i detect encode of characters related to this string? for detecting of encode char i used below code which is not working

echo mb_detect_encoding($tmp);

i put sample of string in my language(persian) here : "کمترین قیمت رزرو شبی ۲۲۸,۰۰۰ تومان" .i want to remove "تومان" from this string and i used below code:

$result = str_replace('تومان','',$tmp);

after i execute my php file in IE show just "?" instead of my string and if i add this code to my php file "header('Content-Type: text/html; charset=utf-8');" display my string with right characters but without remove determined string from it. Do you have any idea to fix this?


Solution

  • i find my problem. In visual studio 2013 go to : Tools > Options > Environment and checked option "Save documents as Unicode when data cannot be saved in codepage". after that everything work perfect.