0

I have a PHP str_replace that replaces every hyphen - that comes right after a slash / by a non-breaking hyphen ̩.

str_replace( '/-', '/‑', $input );

I’d like to extend this str_replace with a second condition that says that also every hyphen that comes before a slash should also be replaced:

str_replace( '-/', '‑/', $input );

How can I merge these to conditions?

0

2 Answers 2

2

You can use an array of values with str_replace:

str_replace(array('/-', '-/'), array('/‑', '‑/'), $input);
Sign up to request clarification or add additional context in comments.

Comments

0

Try:

str_replace(['/-', '-/'], ['/‑', '‑/'], $input);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.