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

search for in the

mb_stripos> <mb_strcut
[edit] Last updated: Fri, 23 Mar 2012

view this page in

mb_strimwidth

(PHP 4 >= 4.0.6, PHP 5)

mb_strimwidthDizgeyi belirtilen genişlikte kırpar

Açıklama

string mb_strimwidth ( string $dizge , int $başlangıç , int $genişlik [, string $kırpıcı [, string $kodlama ]] )

Belirtilen dizge dizgesini genişlik ile belirtilen genişlikten kırpar.

Değiştirgeler

dizge

Kırpılacak dizge.

başlangıç

Kırpma genişliğinin başlatılacağı konum. Dizgenin başından itibaren sayılır. İlk karakterin indisi 0'dır.

genişlik

Kırpma genişliği.

kırpıcı

Dizge kırpılırken dizgenin sonuna eklenen bir dizge.

kodlama

kodlama değiştirgesinde karakter kodlaması belirtilir. Belirtilmediği takdirde dahili karakter kodlaması kullanılır.

Dönen Değerler

Kırpılmış dizge ile döner. kırpıcı belirtilmişse, kırpıcı dönen değere eklenir.

Örnekler

Örnek 1 - mb_strimwidth() örneği

<?php
$str 
mb_strimwidth($str040"..>");
?>

Ayrıca Bakınız



add a note add a note User Contributed Notes mb_strimwidth
CBieser 26-Aug-2008 12:50
<?php
function strimwidthCenter( $value, $length = 40 ) {
   
$valueEncoding = mb_detect_encoding( $value, 'auto', true );
    if (
$length >= mb_strwidth( $value, $valueEncoding ) ) {
        return
$value;
    }
   
$limited = '';
   
$firstWidth = ceil( $length/2 );
   
$secondStart = mb_strwidth( $value, $valueEncoding ) - ( $length - $firstWidth );
   
$secondWidth = $length - $firstWidth +1;
   
$limited = mb_strimwidth( $value, 0, $firstWidth, '...', $valueEncoding ) . mb_substr( $value, $secondStart, $secondWidth, $valueEncoding );
    return
$limited;
}
?>
josiah dot ritchie at gmail dot com 13-Sep-2007 11:48
While having the option to append a string to the end is nice, you can run into the problem of having a space between the append if the width is truncated after a space. I find something like this to be more attractive in the output, although messy in the code.

rtrim(mb_strimwidth($string, 0, 24))."..."

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