Search code examples
phpstringreplacestr-replace

Remove specific kind of text from a string


how I can remove price fields from strings? For example I have n items with various of prices (prices frequently change). 1) VIP Package (80.00 Euro) 2) Standard Package (0.00 Euro) 3) Red Group (25.00 Euro) ... ... n) Yellow Pack (10.00 Euro)

How can I remove the price fields, and display only Name fields like: 1) VIP Package 2) Standard Package 3) Red Group ... ... n) Yellow Pack

I know that the 'str_replace' code can help, but I could not configure it. Please help if you can.


Solution

  • Since the price is dynamic you can use explode('(', $string)[0]