1
你好我怎麼做一個預浸比賽上預浸匹配和替換元素
$string1 = "[%refund%]processed_by"
$string2 = "[%refund%]date_sent"
我要搶裏面%%位,然後取下[%item%]
乾脆。只留下「proccessed_by」或「date_sent」,我已經下過了,但有點卡住了。
$unprocessedString = "[%refund%]date_sent"
$match = preg_match('/^\[.+\]/', $unprocessedString);
$string = preg_replace('/^\[.+\]/', $unprocessedString);
echo $match; // this should output refund
echo $string; // this should output date_sent
該訣竅完美。它也改進了我的邏輯。謝謝 – 2012-03-08 18:33:50