���� haystack �ַ����� needle ��һ�γ��ֵ�λ�ÿ�ʼ����β���ַ�����
haystack�ڸ��ַ����в��ҡ�
needle
��� needle ����һ���ַ�������ô������ת��Ϊ���Ͳ�����Ϊ�ַ�˳��ֵ��
before_needle
��Ϊ TRUE��strstr() ������ needle �� haystack �е�λ��֮ǰ�IJ���(������ needle)��
���� needle �� haystack ���Բ����ִ�Сд�ķ�ʽ�Դ���
����ƥ������ַ�������� needle δ�ҵ������� FALSE��
| �汾 | ˵�� |
|---|---|
| 5.3.0 |
������ѡ�� before_needle ������
|
| 4.3.0 | stristr() ��Ϊ�����ư�ȫ�ġ� |
Example #1 stristr() ����
<?php
$email = 'USER@EXAMPLE.com';
echo stristr($email, 'e'); // ��� ER@EXAMPLE.com
echo stristr($email, 'e', true); // �� PHP 5.3.0 ����� US
?>
Example #2 �����ַ����Ĵ������
<?php
$string = 'Hello World!';
if(stristr($string, 'earth') === FALSE) {
echo '"earth" not found in string';
}
// ���: "earth" not found in string
?>
Example #3 ʹ�÷��ַ��� needle
<?php
$string = 'APPLE';
echo stristr($string, 97); // 97 = Сд��ĸ a
// ���: APPLE
?>
Note: �˺����ɰ�ȫ���ڶ����ƶ���