hello wordpress/ url/ php experts I really appreciate your help in advance.
I set up a wordpress website and the url for example
www.domain.com/hello-world-how-are-you
so what i want to do is within single.php script, i want to parse the url and explode the url by “-” and take “hello” and “you” as a php variable.
i don’t have too much knowledge on the server configuration, it would be great if this can be done using php only.
once again, thank you in advance.
To grab the “page name”
I was able to make this method work with preg_replace to grab arrays of each word (stripping out everything but numbers and letters in a string.
prints:
beach
coast
guard
beach
In short:
The URL needs parsed first, check into the SERVER array (SERVER[‘REQUEST_URI’]) and see what fits your needs. (via
error_log(print_r($_SERVER,1))
)