함수 substr from()

(함수 substr from에서 넘어옴)
substr_from
strstr

1 Bash[ | ]

Bash
Copy
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[ | ]

PHP
Copy
echo strstr('hello world', 'll');
echo strstr('hello world', 'l');
echo strstr('hello world', 'x'); // bool(false)
# llo world
# llo world
#
PHP
Copy
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 같이 보기[ | ]