The code should allow this to create variable $Dots
If the URL was for example:
http://example.com/1/2
It will result with a 1 and $Dots will contain ../ allowing all links/photos to show up easily. If it was to result in 2 it would return ../../ and so on. Though, it just infinitely loops.
<?php
//Set up URL Dots. Fixes directory issues.
$ORIGINAL_DOTS = str_ireplace('/test_link','',$_SERVER['REQUEST_URI']);
$COUNT_DOTS = substr_count($ORIGINAL_DOTS,'/')-1;
$END_DOTS = 0;
$Dots = '';
echo $COUNT_DOTS;
if($COUNT_DOTS != 0){
while ($END_DOTS <= $COUNT_DOTS){
if($END_DOTS != $COUNT_DOTS){
$END_DOTS ++;
$Dots .= '../';
}
}
}
?>
Yes, your loop will run forever.
Consider what will happen when
$END_DOTS == $COUNT_DOTS. The if-block within the loop won’t execute, so the condition$END_DOTS <= $COUNT_DOTSwill remain true, hence the loop will run forever.Instead, you should use