Hello
i'd like to split Benutzer_CRA.php
to get CRA but sometimes the files are called
Benutzer_OVE_CRA.php and therefore the result schould OVE_CRA
how cann i tell preg_split to split the string at the
first occurence of _ and before .php
BR/Torsten
--
PHP General Mailing List
Torsten,
You could use explode on the file name and then only read in the
sections that you want:
$FileName = Benutzer_OVE_CRA.php;
$Part1 = explode(_, $FileName_);
$TotalPart1 = count($Part1);
$Wanted_File_Pieces = array();
// C = 2 so that it will skip the Benutzer part of the filename and
i'd like to split Benutzer_CRA.php
to get CRA but sometimes the files are called
Benutzer_OVE_CRA.php and therefore the result schould OVE_CRA
how cann i tell preg_split to split the string at the
first occurence of _ and before .php
preg_match(/_(.*)\.php/,$str,$matches);
$matches[1]
3 matches
Mail list logo