substr 문자열자르기

PHP 2015. 7. 28. 19:21

http://php.net/manual/kr/function.substr.php

설명 ¶

string substr ( string $string , int $start [, int $length ] )

Returns the portion of string specified by the start and length parameters.

인수 ¶

string

The input string. Must be one character or longer.

start

If start is non-negative, the returned string will start at the start'th position in string, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.

If start is negative, the returned string will start at the start'th character from the end of string.

If string is less than or equal to start characters long, FALSE will be returned.

Example #1 Using a negative start

<?php
$rest 
substr("abcdef", -1);    // returns "f"
$rest substr("abcdef", -2);    // returns "ef"
$rest substr("abcdef", -31); // returns "d"
?>
length


'PHP' 카테고리의 다른 글

array_slice  (0) 2015.07.29
php와 자바의 array 기본적인 쓰임 차이  (0) 2015.07.29
str_replace 문자열치환  (0) 2015.07.28
instanceof  (0) 2015.07.28
이클립스 깔자마자 가장 먼저 설정해줘야할 부분  (0) 2015.07.28
Posted by 이상욱1
,