- substr: documentation ( source)
- strpos: documentation ( source)
<?php
$dir_root = '/coucou/test/install/../';
$dir = '/coucou/test/install/../images/logo/0';
if (strpos($dir, $dir_root) === 0) {
$dir = './' . substr($dir, strlen(DIR_ROOT) + 1);
echo $dir;
}