php

php String Function

hojomu 2023. 8. 24. 08:30

1. strpos    ->   문자열에서 부분 문자열이 처음 나타나는 위치를 찾는다

strpos ( string $haystack , string $needle , int $offset= 0 ): int | false

https://secure.php.net/function.strpos

 

PHP: strpos - Manual

A pair of functions to replace every nth occurrence of a string with another string, starting at any position in the haystack. The first works on a string and the second works on a single-level array of strings, treating it as a single string for replaceme

www.php.net

 

2. strlen    ->   문자열의 길이를 얻는다 ( 띄어쓰기도 읽음 )

strlen ( string $string ): int

 

3. substr   ->    문자열의 일부를 반환

substr ( string $string , int $offset , ? int $length=null ): string

https://www.php.net/function.substr

 

PHP: substr - Manual

may be by following functions will be easier to extract the needed sub parts from a string: here comes the source:

www.php.net