2016-10-16 75 views
-2

我有下面的數據,在一個單元格,在MySQL數據庫:如何在MySQL細胞篩選數據

mc_gross = 213.94 invoice = 8 protection_eligibility = Eligible address_status = confirmed item_number1 = 1379444095 payer_id = UIHUI43SOMEID tax = 0.00 address_street = some address payment_date = 11:57:10 Sep 17, 2013 PDT payment_status = Completed charset = windows-1252 address_zip = 77777 mc_shipping = 0.00 mc_handling = 0.00 first_name = John mc_fee = 5.01 address_country_code = US address_name = John Doe notify_version = 3.7 custom = 8 payer_status = verified business = [email protected] address_country = United States num_cart_items = 1 mc_handling1 = 0.00 address_city = some city verify_sign = [email protected]*key payer_email = [email protected] mc_shipping1 = 0.00 tax1 = 0.00 txn_id = 1RFSOMEID3S payment_type = instant last_name = Doe address_state = AZ item_name1 = Order Number: 1379444095 receiver_email = [email protected] payment_fee = 5.01 quantity1 = 1 receiver_id = GAGESOMEID tx ... 

我怎麼會去等號後過濾信息,只提取數據?

+2

真的不清楚你在問什麼...... – Dekel

+0

@Dekel一旦我運行查詢來選擇數據,我將如何使用PHP來只選擇等號後的數據? –

+0

發佈代碼如何準確獲取該信息。 –

回答

1

我相信你可以使用正則表達式將其分割成鍵,值對,如下所示:

preg_match_all('/[a-zA-Z_]+\s+=+\s+[^\s]+/', $a, $matches); 

因此,基於所提供的串$匹配將包含:

Array 
(
    [0] => Array 
     (
      [0] => mc_gross = 213.94 
      [1] => invoice = 8 
      [2] => protection_eligibility = Eligible 
      [3] => address_status = confirmed 
      [4] => payer_id = UIHUI43SOMEID 
      [5] => tax = 0.00 
      [6] => address_street = some 
      [7] => payment_date = 11:57:10 
      [8] => payment_status = Completed 
      [9] => charset = windows-1252 
      [10] => address_zip = 77777 
      [11] => mc_shipping = 0.00 
      [12] => mc_handling = 0.00 
      [13] => first_name = John 
      [14] => mc_fee = 5.01 
      [15] => address_country_code = US 
      [16] => address_name = John 
      [17] => notify_version = 3.7 
      [18] => custom = 8 
      [19] => payer_status = verified 
      [20] => business = [email protected] 
      [21] => address_country = United 
      [22] => num_cart_items = 1 
      [23] => address_city = some 
      [24] => verify_sign = [email protected]*key 
      [25] => payer_email = [email protected] 
      [26] => txn_id = 1RFSOMEID3S 
      [27] => payment_type = instant 
      [28] => last_name = Doe 
      [29] => address_state = AZ 
      [30] => receiver_email = [email protected] 
      [31] => payment_fee = 5.01 
      [32] => receiver_id = GAGESOMEID 
     ) 
) 
1

從數據庫中檢索數據後,就可以使用這樣preg_mathchpreg_match_all('/\s[^=]+="[^"]+"/', $string, $matches);

1

正則表達式有幾個等號做到這一點。您可以使用正則表達式匹配來收集等號後面/之間的任何或全部零件。