print_r($str);
//preg_match_all("/\"order_id\":[0-9]{3,}/", $str,$match);
//preg_match_all("/^\[user_num\].*$/m", $str,$match);
//preg_match_all("/^\[1\].*$/m", $str,$match);
preg_match_all("/^( *)?\[1\] => {.*/m", $str,$match);
print_r($match);
如果匹配行的开头(加上^或者$),必须添加修饰符m,这样才能匹配多行,否则即使有内存,有只会匹配一行。
http://www.php.net/manual/zh/regexp.reference.anchors.php
[user_num]
[user_num]
[1]
Array
(
[0] => Array
(
[user_id] => 1111111
[email] => 1111@qq.com
[tel] => 11111111111
[name] => 噢噢噢噢
[phone] =>
[route_id] => 215099
[start_city_code] => 1619
[start_time] => 2014-04-05
[back_time] => 2014-04-06
[user_num] => 1
[children_num] => 0
[routes_scheme_id] => 0
[dfc_option] => 4
[dfc_num] => 0
[user_need] =>
[ticket_id] => 0
[start_pos_id] => 296339
[insure_row] => Array
(
[0] => Array
(
[key] => 307
[value] => 1
[price] => 7
[totalPrice] => 7
)
)
[insureTotalPrice] => 7
[campaign] => Array
(
)
[promotionInfoMap] => Array
(
)
[promotionTotalPrice] => 0
[promotionTotalCoupon] => 0
[customer_row] => Array
(
[0] => Array
(
[name] => 噢噢噢噢
[sex] => 1
[paper_type] => 1
[paper_num] => 320204199010013537
[tel] => 11111111111
[birthday] => 0000-00-00
[paper_deadline] => 0000-00-00
[nation] =>
[firstname] =>
[lastname] =>
[gatxz_csd] =>
[gatxz_qfd] =>
[passport_qfd] =>
[has_xgqz] => 0
[xgqz_type] => 1
[xgqz_deadline] => 0000-00-00
[has_amqz] => 0
[amqz_type] => 1
[amqz_deadline] => 0000-00-00
[remark] =>
[visa_type] =>
)
)
[channel_code] => 100
[union_id] => 10716
[inner_num] =>
[p_ext] =>
[partner_code] => 10716
[api_type] => 1
[client_type] => 20
[device_type] => 1
[order_status] => 10
[end_city_code] => 0
[campaign_discount] =>
[campaign_id_special] =>
[agency_user] =>
[customer_realname] =>
[money] =>
[com_phone] =>
[com_address] =>
[com_info] =>
[visa_array] =>
[attach_info] =>
[attach_price] =>
[attach_cost] =>
[groupCost1] => 385
[groupCost2] => 385
[groupCost3] => 376
[travelCouponToUse] => 0
[group_cost] => 376
[coupon_use] => 9
[change_price] => Array
(
[order_id] => 0
[saler] => 39
[change_price] => 0
[adult_price] => 378
[child_price] => 218
[room_add_budget] => 100
[dfc_option] => 4
[dfc_num] => 0
)
[create_type] => 3
[is_login_user] => 1
[is_fast_order] => 1
[sign_type_flag] => 0
[sign_type] => 0
[auto_sign_mark] => 0
)
[1] => {"order_id":1111111,"position":1,"fail_flag":0,"exec_time":0.28448009491,"error":"","campaign_flag":[]}
)