함수 substr from()

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 }}