![](/bink.gif) |
|
| ![](/bink.gif) |
PHP explode ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿ ºÐ¸® |
|
|
![](icon/private_name/1.gif) |
13³â Àü |
[PHP explode ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿ ºÐ¸®]
PHP ¿¡¼ Á¦°øÇÏ´Â explode ÇÔ¼ö´Â ¹®ÀÚ¿À» ƯÁ¤ ¹®ÀÚ¸¦ ±âÁØÀ¸·Î ¹è¿·Î ºÐÇÒÇÏ´Â ÇÔ¼ö·Î ¿©±â¼´Â explode ÇÔ¼ö ¿Ü¿¡ JSPÀÇ StringTokenizer Ŭ·¡½º¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿ ºÐ¸®, ASPÀÇ Split ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿ ºÐ¸®ÀÇ ¿¹±îÁö »ìÆ캸°Ú½À´Ï´Ù. ASP¿¡¼ »ç¿ëµÇ°í ÀÖ´Â Split ÇÔ¼ö´Â PHP¿Í JSP(JAVA)¿¡¼µµ ÆÐÅÏÀ» ÀÌ¿ëÇÑ ¹®ÀÚ¿ ºÐ¸® ¿ëµµ·Î Á¦°øµÇ°í ÀÖ´Â ÇÔ¼ö(¸Þ¼Òµå)À̱⵵ ÇÕ´Ï´Ù.
<?php
// PHPÀÇ explode ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿ ºÐ¸®
$strPhone = "YYYY-XXXX-ZZZZ";
$arrPhone = explode( "-", $strPhone );
for($i=0;$i< sizeof($arrPhone);$i++){
echo $arrPhone[$i];
}
?>
<%@ page import="java.util.*" %>
<%
// JSPÀÇ StringTokenizer Ŭ·¡½º¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿ ºÐ¸®
String strPhone = "YYYY-XXXX-ZZZZ";
String [] arrPhone = null;
StringTokenizer st = new StringTokenizer(strPhone,"-");
int cntToken = st.countTokens();
arrPhone = new String [cntToken];
for( int i = 0; st.hasMoreTokens(); i++ )
arrPhone[i] = st.nextToken();
for( int j = 0; j < cntToken; j++ )
out.println(arrPhone[j]);
%>
JSP(JAVA)¿¡¼ Á¦°øÇÏ´Â StringTokenizer Ŭ·¡½º¿¡¼ Á¦°øÇÏ´Â ¸Þ¼Òµå¿¡´Â ¹®ÀÚ¿À» Àß¶ó¼ ¹è¿·Î ¸®ÅÏÇØÁÖ´Â ¸Þ¼Òµå´Â ¾ø½À´Ï´Ù. ¹è¿¿¡ ´ã°í ½ÍÀ¸¸é À§¿Í °°ÀÌ Á÷Á¢ ¹è¿À» ¼±¾ðÇؼ ó¸®ÇØ ÁÖ¾î¾ß ÇÕ´Ï´Ù.
<%
// ASPÀÇ Split ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ ¹®ÀÚ¿ ºÐ¸®
Dim strPhone, arrPhone
strPhone = "YYYY-XXXX-ZZZZ"
arrPhone = Split( strPhone, "-" )
For i = 0 To Ubound(arrPhone)
response.Write arrPhone(i)
Next
%>
ASPÀÇ Split ÇÔ¼ö´Â Ä£ÀýÇÏ°Ô ¹è¿¿¡ ´ã¾ÆÁÖ°í ÀÖ½À´Ï´Ù. À§¿¡¼ °£´ÜÈ÷ ¾ð±ÞÇßÁö¸¸ Split ÇÔ¼ö¿Í µ¿ÀÏÇÑ À̸§ÀÇ ÇÔ¼ö,¸Þ¼Òµå¸¦ PHP, JSP(JAVA)¿¡¼µµ Á¦°øÇØ ÁÖ°í ÀÖ½À´Ï´Ù.
|
|
̵̧ : 591 |
̵̧
¸ñ·Ï
|
|
| ![](/bink.gif) |
|