Beispiel #1
0
 /**
  * Try to resolve a path
  *
  * @param string $path      The path to be resolved
  * @return string
  */
 function tryresolvepath($path)
 {
     $result = '';
     $path = trim($path);
     if (strlen($path) === 0) {
         return $result;
     }
     $path = is_windows($path) ? str_replace('/', SEP, $path) : str_replace('\\', SEP, $path);
     // Explode by current filesystem path separator
     $pathnodes = str_explode(SEP, $path);
     if (sizeof($pathnodes) > 0) {
         $result = $pathnodes[0];
         foreach ($pathnodes as $node) {
             $result = concat($result, SEP, $node);
             $realpath = realpath($result);
             if (is_string($realpath)) {
                 $result = $realpath;
                 // If current result is a path to file, there's no point trying to resolve for the next node
                 break;
             }
         }
     }
     return $result;
 }
Beispiel #2
0
 public function test_str_explode()
 {
     $this->assertEquals(['a', 'b'], str_explode('a:b', [':']));
     $this->assertEquals(['a', 'b'], str_explode('a:b', ':'));
     $this->assertEquals(['a:b'], str_explode('a:b', []));
     $this->assertEquals(['a', 'b', 'c', 'd'], str_explode('a:b_c#d', [':', '_', '#']));
 }
Beispiel #3
0
echo substr($hanzistr, 0, 17);
$users[] = 'join';
$users = 'jdsfjfjs';
print_r($users);
echo "<br>";
print_r($_SERVER);
function str_explode($str)
{
    $str_arr = explode("_", $str);
    print_r($str_arr);
    $str_implode = implode(" ", $str_arr);
    print_r($str_implode);
    $str_implode = implode("", explode(" ", ucwords($str_implode)));
    return $str_implode;
}
$strexplode = str_explode("make_by_id");
print_r($strexplode);
$str = "make_by_id!";
$expStr = explode("_", $str);
for ($i = 0; $i < count($expStr); $i++) {
    echo ucwords($expStr[$i]);
}
echo str_replace(' ', '', ucwords(str_replace('_', ' ', 'open_door')));
function getExt($url)
{
    $arr = parse_url($url);
    $file = basename($arr['path']);
    echo $file;
    $ext = explode(".", $file);
    return $ext[1];
}