第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

echo $match[0]; //$match[0]和$match[1]區(qū)別在哪?

<?php

//請修改變量p的正則表達式,使他能夠匹配str中的姓名

$p = '/[\w]+(\:[a-z]+\s[\w]+)/';

$str = "name:steven jobs";

preg_match($p, $str, $match);

echo $match[0]; //$match[0]和$match[1]區(qū)別在哪?


正在回答

2 回答

$match是數(shù)組,$match[0]是其第一個元素,是取回的全匹配元素,$match[2]是其第二個元素,是()中指定要的元素。 你可以使用$str="other words name:steven jobs others thing"; 測試print_r($match); 的輸出,會更清晰:

<?php

$p = '/[\w]+\:([a-z]+\s[\w]+)/i';

$str="other words name:steven jobs others thing";

preg_match($p, $str, $match);

print_r($match);

?>


輸出:
Array
(
? ?[0] => name:steven jobs
? ?[1] => steven jobs
)

2 回復(fù) 有任何疑惑可以回復(fù)我~
#1

web_東 提問者

非常感謝!
2016-12-11 回復(fù) 有任何疑惑可以回復(fù)我~

是()中指定要的元素是什么意思?

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
PHP進階篇
  • 參與學(xué)習(xí)       181905    人
  • 解答問題       2646    個

輕松學(xué)習(xí)PHP中級課程,進行全面了解,用PHP快速開發(fā)網(wǎng)站程序

進入課程

echo $match[0]; //$match[0]和$match[1]區(qū)別在哪?

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號