1
이미지 링크를 쉼표로 분리하여 이미지로 변환하고 웹 사이트의 다른 부분에 표시하도록 목록을 구분하는 적절한 방법 인 경우보기에 감사드립니다. 곧 조언을이것은 shift_array와 imploding 및 exploding 문자열의 적절한 방법입니까?
내 코드
<?php
//the array, will be grabbing from database soon
$string = "main.jpg,extra_img_1.jpg,extra_img_2.jpg,extra_img_3.jpg,extra_img_4.jpg,extra_img_5.jpg";
//explode the whole array
$array = explode(',',$string);
//remaking the list turning it back into an array
$oldstring = '<li>'.implode('</li><li>',$array).'</li>';
// removing the first string in the commad array
array_shift($array);
//turning it back into an array without the first listed item
$newstring = '<li>'.implode('</li><li>',$array).'</li>';
//showing the old string in a listed format
echo $oldstring;
echo '<hr>';
// showing the first item in the old string
echo '<li>'.explode(',', $string)[0].'</li>';
echo '<hr>';
//once its shifted, i want to reshow the list
echo $newstring;
?>
감사합니다.
감사합니다, 나는 주위에 몇 가지를 수정하고 그것을 얻을이 두 번째
explode()[0]
할 필요가 없다 작업! – xtrman