(PHP 4, PHP 5, PHP 7)
strrpos — ����ָ���ַ�����Ŀ���ַ��������һ�γ��ֵ�λ��
$haystack
, string $needle
[, int $offset = 0
] ) : int
�����ַ��� haystack �� needle ���һ�γ��ֵ�����λ�á�ע�� PHP4 �У�needle ֻ��Ϊ�����ַ������ needle ��ָ��Ϊһ���ַ�������ô����ʹ�õ�һ���ַ���
haystack�ڴ��ַ����н��в��ҡ�
needle
��� needle����һ���ַ�����������ת��Ϊ���Ͳ�����Ϊ�ַ���˳��ֵ��
offset���������ַ��������ⳤ�ȵ����ַ���������ֵ�����²������ַ�����β����ʼ�ļ���λ�ô�������
���� needle ���ڵ�λ�á����û���ҵ������� FALSE��
Also note that string positions start at 0, and not 1.
Returns FALSE if the needle was not found.
| �汾 | ˵�� |
|---|---|
| 5.0.0 |
���� needle ������һ�����ַ����ַ�����
|
| 5.0.0 |
���� offset ������
|
Example #1 ����ִ��Ƿ����
������"��λ�� 0 ���ҵ�"��"δ�����ַ���"���������������Ǽ������İ취��
<?php
$pos = strrpos($mystring, "b");
if ($pos === false) { // ע��: �����Ⱥ�
// ���...
}
?>
Example #2 ʹ��ƫ��λ�ý��в���
<?php
$foo = "0123456789a123456789b123456789c";
var_dump(strrpos($foo, '7', -5)); // ��β���� 5 ��λ�ÿ�ʼ����
// ���: int(17)
var_dump(strrpos($foo, '7', 20)); // �ӵ� 20 ��λ�ÿ�ʼ����
// ���: int(27)
var_dump(strrpos($foo, '7', 28)); // ���: bool(false)
?>