N
N
nikitoshq2021-10-11 15:01:19
PHP
nikitoshq, 2021-10-11 15:01:19

How to cut extra spaces?

There is a description of the product, for example:

<li>Text</li><li>Dimensions ( cm ): 28 x 18 x 9</li></ul>

You need to remove the spaces inside the brackets, around the "cm":

<li>Text</li><li>Dimensions (cm): 28 x 18 x 9</li></ul>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-10-11
@nikitoshq

preg_replace('~\(\s*cm\s*\)~', '(cm)', $str)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question