发布于 2023-11-12 14:02:27 浏览 317
// 假设 $text 是包含 JSON 数据的字符串
$text = 'Some text before the JSON data {"name": "John", "age": 30} Some text after the JSON data';
// 使用正则表达式匹配整段 JSON 数据
$pattern = '/\{(?:[^{}]|(?R))*\}/';
if (preg_match($pattern, $text, $matches)) {
$json_data = $matches[0];
// 现在 $json_data 包含了整段 JSON 数据
echo $json_data;
} else {
echo "未找到匹配的 JSON 数据。";
}
PHP基础 发布于 2023-11-12 14:01:35 浏览 269
MYSQL 发布于 2023-11-07 18:26:16 浏览 570
MYSQL 发布于 2023-11-07 18:25:12 浏览 573
MYSQL 发布于 2023-11-07 18:17:56 浏览 316
其他 发布于 2023-11-05 17:44:53 浏览 276
其他 发布于 2023-11-05 17:44:33 浏览 272
其他 发布于 2023-11-05 17:44:27 浏览 259