Приготовьтесь к конструктивной критике, пожалуйста.
В этом коде много неправильного.Сначала я добавлю комментарии, чтобы объяснить некоторые ошибки, а также некоторые бессмысленные вещи, которые ничего не делают.
$folderPath="".cdnurl."assets/".pid."";
// 1. Single-quotes will perform slightly better.
// 2. There is no need for the first "". or the final ."" - they do nothing.
// 3. Ideal: $folderPath = cdnurl.'assets/'.pid;
// 4. This assumes that cdnurl and pid are constants declared with the define() command. If they are not constants, you need dollar-signs, which would make it:
// $folderPath = $cdnurl.'assets/'.$pid;
$folderSubNumber => 3;
// You cannot put a "more than X" or "less than X" in a variable. The => is used in foreach() loops for a completely different purpose, and when declaring values in an array only when the array is originally declared. (In other words; in this case, this does nothing.)
// Indentation really does matter. This should be indented the same as the code above.
while(file_exists($folderPath.$folderSubNumber)) {
// 1. $folderSubNumber never changes and so this while-loop always asks the exact same question.
// 2. You don't have a directory separator "/", so this will append $folderSubNumber straight to pid, above.
echo '<li><img src="assets/pid/'.folderSubNumber.'';
// 1. folderSubNumber needs a dollar-sign because it's a variable. If it is not defined as a constant, it will simply be the literal string "folderSubNumber".
// 2. The appended .'' does nothing and shouldn't be there.
// 3. You are neither closing the <img> tag, nor the <li> tag, nor in fact the src-attribute.
// 4. Ideal: echo '<li><img src="assets/pid/'.$folderSubNumber.'" /></li>';
} else {
// 1. There is no "else" in while.
// 2. You don't need an "else" if the intention is to do nothing.
echo "";
// This is 100% pointless, it does nothing.
}
Что вам тогда нужно, это увеличить $ foldeSubNumber после того, как вы попробовали это вцикл while (см. ответ «sdleihssirhc»).Но также обратите внимание, что вам, вероятно, нужен разделитель каталогов между $ folderPath и $ folderSubNumber.Это было бы: $folderPath.'/'.$folderSubNumber
Удачи!