php - is it possible to shrink preg_replace and str_replace -
Is it possible to make it more smooth with the lower line of code because I have to repeat it for every new box Enter
$ fil_namn = str_replace ("5FSE_", "", $ fil_url); $ Fil_namn = str_replace (".pdf", "", $ fil_namn); $ Fil_namn = str_replace (".docx", "", $ fil_namn); $ Fil_namn = str_replace (".doc", "", $ fil_namn); $ Fil_namn = preg_replace ("[_]", ".", $ Fil_namn); $ Fil_namn = preg_replace ('/ ^ [0-9] + \. +', '', $ Fil_namn); $ Fil_namn = preg_replace ("[AAA]", "one", $ fil_namn); $ Fil_namn = preg_replace ("[AEA]", "A", $ fil_namn); $ Fil_namn = preg_replace ("[oo]", "o", $ fil_namn); $ Fil_namn = preg_replace ("[AAA]", "A", $ fil_namn); $ Fil_namn = preg_replace ("[AEA]", "A", $ fil_namn); $ Fil_namn = preg_replace ("[oOo]", "o", $ fil_namn); $ Fil_namn = str_replace (".", "", $ Fil_namn);
You can use it:
Str_replace (array ('5FSE_', '.pdf', '.docx', '.doc'), '', $ fill_namn); str_replace
allows for an array.
You can also:
$ string = "Hello"; Arrow ("A", "L", "E", "X"), $ string (ARE ("H", "E", "L", "O"), array
This will print Aeeex
.
Another method string ()
function:
$ string = "[AAA] [OOO]"; $ Find = array ("[AAA]", "[AAA]", "[AAA]", "[AAA] [AAA] [OAO] [AO]] [AAA] $ [Array] "," [AO] "," [AAA] "," [AAA] "," [oo] "); = $ = array (" one "," one "," ö "," Å "," Ä "," ö "); echo string ($ string, array_combin ($ find, replace $));
It does the following:
ÅäöÅÄö
Comments
Post a Comment