"함수 substr from()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 5개는 보이지 않습니다)
1번째 줄: 1번째 줄:
;substr_from
;substr_from
;strstr
==Bash==
[[category: Bash]]
<syntaxhighlight lang='bash'>
haystack='hello world'
needle='ll'
echo $needle${haystack#*$needle}
# llo world
needle='l'
echo $needle${haystack#*$needle}
# llo world
needle='x'
echo $needle${haystack#*$needle}
# xhello world
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='php'>
<syntaxhighlight lang='php'>
echo strstr('hello world', 'll');
echo strstr('hello world', 'll');
echo strstr('hello world', 'l');
echo strstr('hello world', 'l');
10번째 줄: 26번째 줄:
# llo world
# llo world
#  
#  
</source>
</syntaxhighlight>
<source lang='php'>
<syntaxhighlight lang='php'>
function substr_from($needle, $haystack) { return strstr($haystack, $needle); }
function substr_from($needle, $haystack) { return strstr($haystack, $needle); }


20번째 줄: 36번째 줄:
# llo world
# llo world
#
#
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[함수 substr_after]]
*[[함수 substr_before]]
*[[함수 substr_before]]
*[[함수 substr_until]]
*[[함수 substr]]
*[[함수 substr]]
*[[PHP 함수 substr after, before, from, until]]

2020년 11월 2일 (월) 02:36 기준 최신판

substr_from
strstr

1 Bash[ | ]

haystack='hello world'
needle='ll'
echo $needle${haystack#*$needle}
# llo world
needle='l'
echo $needle${haystack#*$needle}
# llo world
needle='x'
echo $needle${haystack#*$needle}
# xhello world

2 PHP[ | ]

echo strstr('hello world', 'll');
echo strstr('hello world', 'l');
echo strstr('hello world', 'x'); // bool(false)
# llo world
# llo world
#
function substr_from($needle, $haystack) { return strstr($haystack, $needle); }

echo substr_from('ll', 'hello world');
echo substr_from('l', 'hello world');
echo substr_from('x', 'hello world'); // bool(false)
# llo world
# llo world
#

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}