| 제목 | str_replace 개행문자처리 궁금한점이있습니다. | ||
|---|---|---|---|
| 카테고리 | CI 2, 3 | ||
| 글쓴이 | Givepro | 작성시각 | 2016/09/26 15:42:58 |
|
|
|||
textarea태그의 내용중 줄바꿈을 위해서 str_replace를써서 처리했습니다.
$product_name = str_replace("\r\n", "<BR/>", $product_name);
하지만 궁금한게 있습니다. 여기서 \r\n을 <br/>로 치환을했는데요 제가 연습중인 ci controller modify.php에서는
// 번호에 해당하는 데이터 가져오기
$idx = $this->uri->segment(3);
$data['views'] = $this -> soft_model -> get_view_progress($idx);
// view 호출
$this -> load -> view('list/soft_progress/progress_detail', $data);
이렇게보여주고있는데요. $data['views'] 이거 자체에서 치환하는방법이있을까요? 저는 상세페이지를 내용 보면서 동시에 수정할수있도록 페이지를 만들었습니다. 수정(상세)페이지로가면 <br>태그가 자꾸보이게되는데 저 함수에대해 이해는하겠는데 $data['views']에서 막힙니다... 선배님들 도움부탁드립니다.
문제발생 메소드
function view_progress() {
// 번호에 해당하는 데이터 가져오기
$idx = $this->uri->segment(3);
$data['views'] = $this -> soft_model -> get_view_progress($idx);
// view 호출
$this -> load -> view('list/soft_progress/progress_detail', $data);
if ( $_POST )
{
// 글쓰기 POST 전송 시
$this->load->helper('alert');
$product_name = trim($this->input->post("product_name"));
$version = trim($this->input->post("version"));
$company = trim($this->input->post("company"));
$purpose = trim($this->input->post("purpose"));
$target = trim($this->input->post("target"));
$compatibility = trim($this->input->post("compatibility"));
$sirial_num = trim($this->input->post("sirial_num"));
$package = trim($this->input->post("package"));
$license_numb = trim($this->input->post("license_numb"));
$keep_place = trim($this->input->post("keep_place"));
$use_num = trim($this->input->post("use_num"));
$remarks = trim($this->input->post("remarks"));
// 개행문자 처리
$product_name = str_replace("\r\n", "<BR/>", $product_name); //줄바꿈 처리
$params = array(
"product_name" => $product_name,
"version" => $version,
"company" => $company,
"purpose" => $purpose,
"target" => $target,
"compatibility" => $compatibility,
"sirial_num" => $sirial_num,
"package" => $package,
"license_numb" => $license_numb,
"keep_place" => $keep_place,
"use_num" => $use_num,
"remarks" => $remarks,
"idx" => $idx
);
$this->soft_model->modify_soft_progress($params);
alert('게시물 수정 완료','../progress_list');
exit;
}
}
|
|||
| 다음글 | 메일발송할때 메일양식 include... (6) | ||
| 이전글 | 페이징 에러 질문있습니다.. (2) | ||
|
전상민
/
2016/09/26 15:45:37 /
추천
0
|
|
Givepro
/
2016/09/26 15:55:15 /
추천
0
말씀하신 댓글의 내용이 이해가 안되서 질문을 다시올립니다. data['view']에서 가져온 내용은 <?php foreach ($progress_list as $lt) { ?> <tr> <td><?php echo $lt->idx; ?></td> <td> <a href="/soft/view_progress/<?php echo $lt->idx ?>"><?php echo $lt->product_name; ?></a> </td> <td><?php echo $lt->version; ?></td> <td><?php echo $lt->company; ?></td> <td><?php echo $lt->purpose; ?></td> <td><?php echo $lt->target; ?></td> <td><?php echo $lt->sirial_num; ?></td> <td><?php echo $lt->package; ?></td> <td><?php echo $lt->license_numb; ?></td> <td><?php echo $lt->keep_place; ?></td> <td><?php echo $lt->use_num; ?></td> <td><?php echo $lt->remarks; ?></td> </tr> <?php } ?> 이런식의 foreach구문에서는 어떻게 적용을 해야할까요.. |
|
Givepro
/
2016/09/26 15:58:21 /
추천
0
자답 아 댓글에서 써주신 함수 정확히 이해했습니다! echo에서 나타내는 값들에 위함수를 적용만해주면 되는 간단한문제였네요ㅜㅜ nl2br($lt->product_name) 전상민님 답변감사합니다! |
저장시에는 str_replace 하지 마시고
화면에 출력할때 아래 함수를 이용해보세요.
http://php.net/nl2br