Toai Luong
Toai Luong

Reputation: 101

Php preg_match not working with content from Curl

This my code

$urlArray = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
$result = curl_exec($ch);

When I use print_r($result) => result is:Tên Huyệt Mệnh Môn:

Thận khí là gốc của cơ thể. Huyệt nằm giữa 2 huyệt Thận Du, là cửa trọng yếu của sinh mệnh, vì vậy gọi là Mệnh Môn (Trung Y Cương Mục).

but I use preg_match('|Tên Huyệt(.*)|', $result, $matches) it return array empty. I don't know why. Anyone tell me why, pls.

Upvotes: 0

Views: 377

Answers (1)

Elon Than
Elon Than

Reputation: 9765

You have to use u modifier to correctly interpret UTF-8 strings.

preg_match('|Tên Huyệt(.*)|u', $result, $matches)

You can read a bit more about this here.

Upvotes: 1

Related Questions