1. explode(string token, string str)
: 문자열 나누기, 문자열 분리하기
$str="#36(SW12),#37(SW12)";
$result=explode(',',$str);
결과
$result[0]에는 #36(SW12)
$result[1]에는 #37(SW12)
가 각각 저장되어 있다.
2. substr(string str, int start, int length)
: start 0부터 시작됨
$str="#36(SW12)"
$result=substr($str,1,2);
결과
$result에는 "36" 이 저장되어있다.
3. strlen(string str)
: 문자열의 길이를 잰다
$str="#36(SW12)"
$length=strlen($str) : 9
$result=substr($str,4,$length-5);
결과
$length : 9
$result : SW12
4. 갯수
$str="#36(SW12),#37(SW12)";
$result=explode(',',$str);
$cnt=count($result);
// or $cnt=sizeof($result);
// or $cnt=substr_count($str,',')+1;
'HTML' 카테고리의 다른 글
★ php substr ★ JSP 블로그 - PHP 함수 모음 (0) | 2011.05.09 |
---|---|
★ APM php apache ★ 神明 - APM 설치 (0) | 2011.05.09 |
★ php substr ★ JSP 블로그 - file()관련함수 (0) | 2011.05.09 |
★ php substr ★ JSP 블로그 - String 함수 목록 (0) | 2011.05.08 |
★ APM php apache ★ 마음평화 - APM setup localhost (0) | 2011.05.08 |