mb_strwidth

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_strwidthReturn width of string

Beschreibung

mb_strwidth(string $string, ?string $encoding = null): int

Returns the width of string string, where halfwidth characters count as 1, and fullwidth characters count as 2. See » http://www.unicode.org/reports/tr11/ for details regarding East Asian character widths.

The fullwidth characters are: U+1100-U+115F, U+11A3-U+11A7, U+11FA-U+11FF, U+2329-U+232A, U+2E80-U+2E99, U+2E9B-U+2EF3, U+2F00-U+2FD5, U+2FF0-U+2FFB, U+3000-U+303E, U+3041-U+3096, U+3099-U+30FF, U+3105-U+312D, U+3131-U+318E, U+3190-U+31BA, U+31C0-U+31E3, U+31F0-U+321E, U+3220-U+3247, U+3250-U+32FE, U+3300-U+4DBF, U+4E00-U+A48C, U+A490-U+A4C6, U+A960-U+A97C, U+AC00-U+D7A3, U+D7B0-U+D7C6, U+D7CB-U+D7FB, U+F900-U+FAFF, U+FE10-U+FE19, U+FE30-U+FE52, U+FE54-U+FE66, U+FE68-U+FE6B, U+FF01-U+FF60, U+FFE0-U+FFE6, U+1B000-U+1B001, U+1F200-U+1F202, U+1F210-U+1F23A, U+1F240-U+1F248, U+1F250-U+1F251, U+20000-U+2FFFD, U+30000-U+3FFFD. All other characters are halfwidth characters.

Parameter-Liste

string

The string being decoded.

encoding

Der Parameter encoding legt das Zeichenencoding fest. Wird er nicht übergeben so wird die interne Zeichenkodierung genutzt.

Rückgabewerte

The width of string string.

Changelog

Version Beschreibung
8.0.0 encoding ist nun nullable (akzeptiert den null-Wert).

Beispiele

Beispiel #1 mb_strwidth() example

<?php
var_dump
(
    
mb_strwidth('a'),       // LATIN SMALL LETTER A
    
mb_strwidth("\u"// FULLWIDTH LATIN SMALL LETTER A
);
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

int(1)
int(2)

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

U4GM How to Get Ready for PoE 3 28 Mirage League

There's a lot to chew on with Path of Exile 3.28, and that's probably why so many players are already planning builds months ahead. Mirage doesn't ...

Geschrieben von StormyWings am 16.04.2026 07:58:25
Forum: Off-Topic Diskussionen
U4GM What Makes the Nova Enchant Sorc So Good in D2R

Running Sorceress in Season 13 doesn't have to mean another safe, predictable Blizzard start and a slow march toward pure Lightning. I went the ot ...

Geschrieben von StormyWings am 16.04.2026 07:55:07
Forum: Off-Topic Diskussionen
U4GM Where to Farm Diablo 4 Season 12 Items Fast

Season 12 clicked for me a lot faster than I expected, mostly because the whole Butcher angle actually changes how you play instead of just dressi ...

Geschrieben von StormyWings am 16.04.2026 05:38:34
Forum: Off-Topic Diskussionen
Diablo 4 Season 13 No PTR? Full Guide to Release Date, Changes

Diablo 4 Season 12 is currently underway, and I believe many players, like myself, are already eagerly anticipating Season 13! However, according ...

Geschrieben von abnerRRR am 16.04.2026 03:55:07
Forum: Off-Topic Diskussionen