downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

strpos> <strncmp
[edit] Last updated: Fri, 17 May 2013

view this page in

strpbrk

(PHP 5)

strpbrkBelirtilen karakterleri bir dizge içinde arar

Açıklama

string strpbrk ( string $dizge , string $karakterler )

strpbrk() işlevi dizge içinde karakterler'den birini bulmaya çalışır.

Değiştirgeler

dizge

Karakterlerin aranacağı dizge.

karakterler

Karakterler harf büyüklüğüne duyarlı olarak aranır.

Dönen Değerler

Bulunan karakterle başlayan dizgeyi döndürür, aranan hiçbir karakter bulunamazsa FALSE döner.

Örnekler

Örnek 1 - strpbrk() örneği

<?php

$text 
'This is a Simple text.';

// ilk eşleşen 'i'den itibaren çıktılanacağından
// "is is a Simple text." basılır
echo strpbrk($text'mi');

// İşlev harf büyüklüğüne duyarlı arama yaptığından
// "Simple text." basılacaktır
echo strpbrk($text'S');
?>



add a note add a note User Contributed Notes strpbrk - [2 notes]
up
1
Evan
5 years ago
If you're not looking to duplicate the rest of the string, but instead just want the offset, in the spirit of the str*pos() functions:

<?php

function strpbrkpos($s, $accept) {
 
$r = FALSE;
 
$t = 0;
 
$i = 0;
 
$accept_l = strlen($accept);

  for ( ;
$i < $accept_l ; $i++ )
    if ( (
$t = strpos($s, $accept{$i})) !== FALSE )
      if ( (
$r === FALSE) || ($t < $r) )
       
$r = $t;

  return
$v;
}

?>
up
-2
root at mantoru dot de
5 years ago
A simpler (and slightly faster) strpbrkpos function:

<?php
function strpbrkpos($haystack, $char_list) {
   
$result = strcspn($haystack, $char_list);
    if (
$result != strlen($haystack)) {
        return
$result;
    }
    return
false;
}
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites