2
What is the correct way to 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
?>
Why the result is preg-replace
and not preg replace
.
Because it doesn’t make a mistake, it just doesn’t work as expected.
My question is how to assign the function result file_name()
(the string "preg-replace") to a variable and then use that variable...
Check this out
echo
where it should bereturn
. I don’t quite understand the purpose of the question. It’s just a replace in the file name?– Papa Charlie