Chvanikoff
Chvanikoff

Reputation: 1329

How to compare 2 different string that link to 1 directory?

For example, next 2 vars give a link to same directory, but strings are different.
How can I detect they means same directory?

$dir1 = 'application/somedir/some_subdir/../';
$dir2 = 'application/somedir/';

Upvotes: 0

Views: 159

Answers (1)

Petah
Petah

Reputation: 46060

Use realpath()

if (realpath($dir1) == realpath($dir2)) {
    do_stuff();
}

See http://php.net/manual/en/function.realpath.php

You may also want to check that the directories exists before use it.

Upvotes: 10

Related Questions