【发布时间】:2019-04-03 21:23:15
【问题描述】:
我需要所需的输出,无论是 preg_match 还是 explode 都不是问题。我需要给定数组格式的输出。
我正在尝试从这个变量中拆分字符串
输入
嗨,FF_nm, 您的城市是 FF_city,您的性别是 FF_gender。网络研讨会标题为 FF_extraparam1 你的名字又是 FF_nickname
输出
array => [昵称,城市,性别,extraparam1,昵称]
代码
<?php
$data = "Hi FF_nm,
Your city is FF_city and your gender is FF_gender. webinar title is FF_extraparam1
Again your name is FF_nickname";
if (($pos = strpos($data, "FIELDMERGE_")) !== FALSE) {
$whatIWant = substr($data, $pos+1);
}
echo $whatIWant;
?>
【问题讨论】:
-
有什么问题?您正在尝试或想要的
preg_*用法是什么? -
我需要所需的输出,无论是 preg_match 还是 explode 都不是问题。我需要给定数组格式的输出
标签: php arrays preg-replace preg-match