I
I
Ivan2018-04-08 23:29:42
PHP
Ivan, 2018-04-08 23:29:42

How to replace part of url with PHP?

There is a link (url)
$url = " https://site.ru/news/502 ";
How to add avto after news?
So that the result would be like this
https://site.ru/news/avto/502
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RichardXXX, 2018-04-08
@RichardXXX

regular expressions read the topic there are functions like printf
develop your router your
route
'/news/([az])/[502]' =>' /new/$1/$2'
Written with errors but understand the meaning and read

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question