- array_shift: documentation ( source)
- implode: documentation ( source)
- explode: documentation ( source)
- in_array: documentation ( source)
<?php
$strings = [
"en/",
"en/account/login",
"en/account/dashboard",
"fa/account/login"
];
$langs = ["en", "fa"];
foreach ($strings as $string) {
$parts = explode('/', $string);
if (in_array($parts[0], $langs)) {
array_shift($parts);
}
echo implode('/', $parts) . PHP_EOL;
}