I know I can convert the filename from .xlsx
to .csv
like this:
$pFileName = "hello.xlsx"
str_replace(".xlsx", ".csv", $pFileName);
... and convert .xls
to .csv
like this:
$pFileName = "hello.xls"
str_replace(".xls", ".csv", $pFileName);
My question is, how can I make a single function that converts my filename to .csv
if its .xlsx
or .xls
? This means, "change the file name to .csv if it's .xls or xlsx in one single (if it's possible) str_replace
.
I tried with a double str_replace
with no luck:
str_replace(str_replace(".xlsx", ".csv", $pFileName), ".csv", $pFileName)
Thanks in advance.