How to properly perform the following assignment:
preg-replace.php
<?php
function file_name(){
$pg = $_SERVER["PHP_SELF"];
echo $path_parts = pathinfo($pg, PATHINFO_FILENAME);//preg-replace
}
$string = file_name();//<<<---- como fazer isso corretamente
$string_f = preg_replace('/-/',' ',$string);
echo $string_f;//preg replace <<---resultado esperado
?>
Because the result is preg-replace
and not preg replace
.
Why do not you give an error, it just does not work as expected.
My question is how to assign the result of the file_name()
function (the "preg-replace" string) to a variable and then use that variable ...