g

이 소스에서 $row[po_content] 글자수 제한하는방법좀 알려주세요

· 2012-04-07 (토) 15:56:55 · 1959 · 7
echo <<<HEREDOC
<tr height=25 align="center">
<td height="24">$row[po_datetime]</td>
<td align="left" title='$row[po_content]'><nobr style='display:block; overflow:hidden;'> $row[po_content]</a></td>
<td align=right>{$point1} </td>
<td align=right>{$point2} </td>
</tr>
HEREDOC;
}

이 소스에서 $row[po_content]를 어떻게 바꿔야 글자수가 제한될까요?ㅜ
검색해서 찾아봐도 여기에 맞는 소스는 찾지 못찾겠더라구요
아시는분 답변 부탁드립니다^^
|

댓글 7개

2012-04-07 (토) 16:37:43
mb_substr 글자수 단위로 자릅니다.
echo mb_substr('테스트입니다감사합니다.',0,5,'utf-8');
결과 -> 테스트입니

substr 바이트 단위로 자릅니다.
substr($row[po_datetime], 0, 70);

cut_str 그누보드 내부 함수 바이트 단위로 자릅니다.
cut_str($row[po_datetime],70)
답변감사합니다^^
근데 위 소스를 어느부분에 삽입해야할까요?
예를들어 cut_str($row[po_content],70)를
그냥 $row[po_content]를 지우고 그대로 넣는건 안될거같은데..
2012-04-07 (토) 22:04:19
실제로 해보니 잘 안되네요...^^;;;;;; (HEREDOC안에서는 함수도 안먹고 cut_str에 배열로 하니 잘 안되고...)

아래처럼 하시면 됩니다.

$row_po_content=$row[po_content];
$row_po_content=cut_str($row_po_content,70);
echo <<<HEREDOC
<tr height=25 align="center">
<td height="24">$row[po_datetime]</td>
<td align="left" title='$row_po_content'><nobr style='display:block; overflow:hidden;'> $row_po_content</a></td>
<td align=right>{$point1} </td>
<td align=right>{$point2} </td>
</tr>
HEREDOC;
친절한 답변 감사드립니다~^^ 적용해보겠습니다!!ㅎㅎ
$sum_point1 = $sum_point2 = 0;

$sql = " select *
$sql_common
$sql_order
limit $from_record, $rows ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
$point1 = $point2 = 0;
if ($row[po_point] > 0) {
$point1 = "+" . number_format($row[po_point]);
$sum_point1 += $row[po_point];
} else {
$point2 = number_format($row[po_point]);
$sum_point2 += $row[po_point];
}

$row_po_content=$row[po_content];
$row_po_content=cut_str($row_po_content,15);
echo <<<HEREDOC
<tr height=25 align="center">
<td height="24">$row[po_datetime]</td>
<td align="left" title='$row[po_content]'><nobr style='display:block; overflow:hidden;'> $row[po_content]</a></td>
<td align=right>{$point1} </td>
<td align=right>{$point2} </td>
</tr>
HEREDOC;
}


이렇게 적용을 시켰는데 적용이 되지 않네요 ㅜㅜ
2012-04-08 (일) 10:33:33
$row_po_content=$row[po_content];
$row_po_content=cut_str($row_po_content,15);

위 코드에서 $row[po_content] 를 $row_po_content 라고 정의 하였으니...
아래 코드 에서도 고쳐줘야 겠죠.

echo <<<HEREDOC
<tr height=25 align="center">
<td height="24">$row[po_datetime]</td>
//이부분 $row[po_content] 를 $row_po_content로 수정 2군데.
<td align="left" title='$row_po_content'><nobr style='display:block; overflow:hidden;'> $row_po_content</a></td>
<td align=right>{$point1} </td>
<td align=right>{$point2} </td>
</tr>
HEREDOC;
적용 되는군여!!ㅎㅎ 정말 감사해요^0^
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

66,531건

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
12-04-09 조회 1,306
12-04-09 조회 957
12-04-09 조회 1,087
12-04-09 조회 1,347
12-04-09 조회 1,684
12-04-08 조회 1,097
12-04-08 조회 1,022
12-04-08 조회 1,753
12-04-08 조회 1,851
12-04-08 조회 1,799
12-04-08 조회 1,628
12-04-07 조회 1,026
12-04-07 조회 2,892
12-04-07 조회 1,960
12-04-07 조회 1,624
12-04-07 조회 1,129
12-04-07 조회 1,812
12-04-07 조회 2,653
12-04-07 조회 1,639
12-04-07 조회 1,280