嗨伙计我有一块文本,我想分成三部分,但我注意到这些部分没有什么共同点,我可以用作explode()函数的分隔符。字符串到3阵列与PHP
$description = '£5.97 for a Pillowheads Children’s Backpack worth £11.95 from Intelex Ltd - save 50% on your choice of five adorable designsNeed to know: Save 50% on an Intelex Ltd Pillowheads Children’s Backpack; Choose from five cute and cuddly designs; Postage and packaging is not included and costs £3.95; The perfect stocking filler this Christmas; What & why: Give your little ones an adorably cute, yet totally practical gift this Christmas with a cuddly creature that doubles as a backpack! For just £5.97 choose one of these gorgeous little Pillowheads Children’s Backpacks from Intelex Ltd. With a gorgeous selection of five fluffy animals to choose from, there's sure to be a pack to suit your little pride and joy! Designed with high-quality adjustable back straps and an inner lining for maximum support, these versatile bags will please even the most fussiest of toy lovers! choose one of the following designs: - Cosy Bee - Ladybird - Monkey - Pig - Puppy Each backpack is 43cm x 20xm in size and can be surface cleaned with a damp sponge. about Intelex Ltd Innovators of the muscle-relieving microwaveable herbal heat pack, Intelex Ltd have set the industry standard for quality and safety. Discover an inexpensive, fun and soothing way to relax in comfort at home with a range of products that combine practicality, comfort and style.By the way: Multiple vouchers may be purchased; This product is suitable for children aged three years ; and over; To order, please phone 0871 911 1770 , quoting your unique kgbdeals voucher code, stating which style you would like and provide your delivery details; Please allow 48 hours for your voucher code to be ; activated';
有没有什么办法可以分割这3块需要知道:什么,为什么,顺便说一句?
编辑:
$description = preg_split('/Need to know:| What & why:|By the way:/i', $product['text']['desc'], 3);
好得到了,顺便位阵列,但“需要知道”和“什么&为什么”位在同一阵列门槛,任何人都可以在这方面帮助? :)
我想你会需要找到另一种方式来获得你想要的信息。不知道你从哪里获取这些数据,但我认为你是从一个网站上获取这些数据的。通常当有这样的描述时,其他地方就会出现故障(如产品名称和价格)。 – Jemaclus 2011-12-14 19:27:11
你的意思是哪三个部分? – TimWolla 2011-12-14 19:27:42
此数据来自网站是其关联企业的广告客户Feed。描述是需要拆分的部分,其余的都很好:) @Jermaclus,谢谢:) – 2011-12-14 19:30:49