사이트 내 전체검색
PHP
[PHP] explode() : 지정된 문자기준으로 배열만들기 (2008/07/14 수정)
로빈아빠
https://cmd.kr/php/630 URL이 복사되었습니다.

본문

PHP의 explode() , list() ASP의 split() 비교

# PHP의 explode()

$tel = 111-222-333
list($tel1,$tel2, $tel3) = explode("-", $tel);
echo $tel1 . "<br>" . $tel2 . "<br>" . $tel3 ;


사용형식: explode("기준문자","나눌변수명")
 
예)
<?
$test="1|2|3|4|5";
$test2=explode("|",$itest);

echo $test2[0];
echo $test2[1];
echo $test2[2];
echo $test2[3];
echo $test2[4];
?>

결과)
12345
 

예)
<?
$test="010-1234-5678";

$test2=explode("-",$test);
echo $test2[0];
echo $test2[1];
echo $test2[2];
?>
 
결과)
01012345678

댓글목록

등록된 댓글이 없습니다.

PHP
871 (7/18P)

Search

Copyright © Cmd 명령어 18.216.220.21