A
A
Anton2021-06-25 04:37:15
PHP
Anton, 2021-06-25 04:37:15

We clean the title when adding, preg_replace, how to replace characters?

Hello.
How can I replace " " in the header with ( )
And / with - with a space before and after so that it is like this, the model is 1456

I have a code that processes the header, at the moment it cleans up extra spaces.

private function creanPrname($prod)
  {
    $prod->prname = preg_replace('/\s{2,}/', ' ', trim($prod->prname));
    $prod->save();
  }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question