- 입력:
국문 / 영문
- 원하는 출력:
국문
/ 영문
<?php
// 먼저 함수를 선언 (for문 위쪽에 배치)
function formatTitle($title, $for_html = true)
{
// 기본 포맷팅: '/' 앞에 줄바꿈 추가
$formatted = str_replace(' /', "\n/", $title);
// HTML 출력용이라면 \n을 <br>로 변환
if ($for_html) {
$formatted = nl2br($formatted);
}
return $formatted;
}
?>
<ul id="gall_ul" class="gall_row">
<?php for ($i = 0; $i < count($list); $i++) {
$classes = array();
$classes[] = 'gall_li';
$classes[] = 'col-gn-' . $bo_gallery_cols;
if ($i && ($i % $bo_gallery_cols == 0)) {
$classes[] = 'box_clear';
}
if ($wr_id && $wr_id == $list[$i]['wr_id']) {
$classes[] = 'gall_now';
}
$line_height_style = ($board['bo_gallery_height'] > 0) ? 'line-height:' . $board['bo_gallery_height'] . 'px' : '';
$thumb = get_list_thumbnail($board['bo_table'], $list[$i]['wr_id'], $board['bo_gallery_width'], $board['bo_gallery_height'], false, true);
// if ($thumb['src']) {
// $img_content = '<img src="' . $thumb['src'] . '" alt="' . $thumb['alt'] . '" >';
// } else {
// $img_content = '<span class="no_image" style="' . $line_height_style . '">no image</span>';
// }
echo run_replace('thumb_image_tag', $img_content, $thumb);
?>
<li class="list" style="background-image: url('<?= $thumb['src']; ?>');">
<div class="gall_chk chk_box">
<?php if ($is_checkbox) { ?>
<input type="checkbox" name="chk_wr_id[]" value="<?php echo $list[$i]['wr_id'] ?>" id="chk_wr_id_<?php echo $i ?>" class="selec_chk">
<label for="chk_wr_id_<?php echo $i ?>">
<span></span>
<b class="sound_only"><?php echo $list[$i]['subject'] ?></b>
</label>
<?php } ?>
<span class="sound_only">
<?php
if ($wr_id == $list[$i]['wr_id'])
echo "<span class=\"bo_current\">열람중</span>";
else
echo $list[$i]['num'];
?>
</span>
</div>
<a href="<?php echo $list[$i]['href'] ?>">
<i class="xi-plus"></i>
<p class="list__title">
<?php
$title = $list[$i]['subject'];
$formatted_html = formatTitle($title, true);
echo $formatted_html;
?>
</p>
</a>
</li><!-- .list -->
<?php } ?>
<?php if (count($list) == 0) {
echo "<li class=\"empty_list\">게시물이 없습니다.</li>";
} ?>
</ul>
주요,,
<?php
// 먼저 함수를 선언 (for문 위쪽에 배치)
function formatTitle($title, $for_html = true)
{
// 기본 포맷팅: '/' 앞에 줄바꿈 추가
$formatted = str_replace(' /', "\n/", $title);
// HTML 출력용이라면 \n을 <br>로 변환
if ($for_html) {
$formatted = nl2br($formatted);
}
return $formatted;
}
?>
<p class="list__title">
<?php
$title = $list[$i]['subject'];
$formatted_html = formatTitle($title, true);
echo $formatted_html;
?>
</p>
728x90