$str 中的字符串是动态的,可能是有一个item#也有可能有多个item#...我要取出所有item#号后的字符串...各位大xia帮帮忙

解决方案 »

  1.   

    我要的是ITEM#号后的:
    380068300804 Item Title: 10pcs Nakamichi Gold Plate Audio Banana Speaker Plug Item URL: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=380068300804 Quantity: 1 Price: $12.99 USD Subtotal: $12.99 USD 这么多内容
      

  2.   


    $str = "Item #: 160289357722 Item Title: 4 pair Amplifier Terminal Binding Post Banana Plug Jack Item URL: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=160289357722 Quantity: 1 Price: $8.99 USD Subtotal: $8.99 USD 
    ---------------------------------------------------------------- Item #: 380068300804 Item Title: 10pcs Nakamichi Gold Plate Audio Banana Speaker Plug Item URL: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=380068300804 Quantity: 1 Price: $12.99 USD Subtotal: $12.99 USD 
    ";
    preg_match_all('/(Item\s*#:\s*\d+)/',$str,$arr);
    print_r($arr);