我有以下代碼我如何讓我的preg_match顯示第一個實例?
$atk="[2] Skedaddle (20) Shuffle Aipom and all basic Energy cards attached to it into your deck. (Discard all other cards attached to Aipom.) (If you have no Benched Pokemon, this attack does nothing.)";
preg_match('#\[(.*)\] (.*) \((.*)\) (.*)#', $atk2, $matchatk2);
$atkcost = $matchatk2[1];
$atkname = $matchatk2[2];
$atkdmg = $matchatk2[3];
$atktext = $matchatk2[4];
它它返回以下:
2
Skedaddle (20) Shuffle Aipom and all basic Energy cards attached to it into your deck.
Discard all other cards attached to Aipom.
(If you have no Benched Pokemon, this attack does nothing.)
我需要它返回:
2
Skedaddle
20
Shuffle Aipom and all basic Energy cards attached to it into your deck. (Discard all other cards attached to Aipom.)(If you have no Benched Pokemon, this attack does nothing.)
我已經perg_match_all嘗試,但它返回相同的結果。
我已經找遍了所有關於我的問題的答案,並找不到與它有關的答案。
預先感謝您。
如果我的回答幫你,請考慮接受其爲正確答案。韓國社交協會。 –