explode를 사용할때 2개의 파라미터만 사용했었는데
우연히 php manual에서 3번째 파라미터값 사용법을 봐서 올립니다.
팁이랄꺼까진 없지만 매번 팁자료실에서 다른분들의 정보를 보고 많이 배워가는게 고마워서 저도 글하나 남겨 볼려고
적었습니다.
<?php
$str = 'one|two|three|four';
// positive limit
print_r(explode('|', $str, 2));
// negative limit (since PHP 5.1)
print_r(explode('|', $str, -1));
?>
우연히 php manual에서 3번째 파라미터값 사용법을 봐서 올립니다.
팁이랄꺼까진 없지만 매번 팁자료실에서 다른분들의 정보를 보고 많이 배워가는게 고마워서 저도 글하나 남겨 볼려고
적었습니다.
<?php
$str = 'one|two|three|four';
// positive limit
print_r(explode('|', $str, 2));
// negative limit (since PHP 5.1)
print_r(explode('|', $str, -1));
?>
The above example will output:
Array
(
[0] => one
[1] => two|three|four
)
Array
(
[0] => one
[1] => two
[2] => three
)
php 5.1부터 추가되었습니다.
|
댓글을 작성하시려면 로그인이 필요합니다.
댓글 1개