frank5050 Posted February 24, 2011 Share Posted February 24, 2011 Hi, Given below is the output of a field from a mySQL/php query: Product ID: 8457, Product Qty: 3, Product SKU: M-242, Product Name: DCE/DTE DB60 Crossover Cable - 1FT, Product Weight: 1, Product Variation Details: , Product Unit Price: 4.68, Product Total Price: 14.04|Product ID: 8800, Product Qty: 1, Product SKU: M-1038, Product Name: RJ45 8P8C Plug Flat Stranded 50pcs/Bag, Product Weight: 1, Product Variation Details: , Product Unit Price: 3.42, Product Total Price: 3.42|Product ID: 8940, Product Qty: 1, Product SKU: M-1385, Product Name: RJ11/12/45 Crimp Tool with Ratchet [HT-568R], Product Weight: 1, Product Variation Details: , Product Unit Price: 9.89, Product Total Price: 9.89 How can I add a <br> before every occurance of the term "Product" (without quotes). That would make the output legible. Should it be done client side, or server side. I can use help for both. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/228741-manipulating-phpmysql-output/ Share on other sites More sharing options...
Rifts Posted February 24, 2011 Share Posted February 24, 2011 $text = preg_replace("Product", "Products<br />", $text); that might work Link to comment https://forums.phpfreaks.com/topic/228741-manipulating-phpmysql-output/#findComment-1179291 Share on other sites More sharing options...
Psycho Posted February 24, 2011 Share Posted February 24, 2011 str_replace() would be much more efficient for a simple replacement such as this $text = str_replace("Product", "<br />\nProduct", $text); But why is all that text in a single database field. You should have each of those pieces of data in unique fields. Link to comment https://forums.phpfreaks.com/topic/228741-manipulating-phpmysql-output/#findComment-1179296 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.