★ wanayoo — archive 1999 http://fr.php.net/manual/de/function.chop.phpNouvelle recherche | Portail wanayoo
PHP  
downloads | documentation | faq | getting help | reporting bugs | php.net sites | links 
search for in the  
previousbin2hexchrnext
Last updated: Thu, 25 Jul 2002
view the printer friendly version or the printer friendly version with notes or change language to English | Brazilian Portuguese | Chinese | Czech | Dutch | Finnish | French | Hungarian | Italian | Japanese | Korean | Polish | Romanian | Russian | Spanish | Turkish

chop

(PHP 3, PHP 4 )

chop -- Entfernt Leerzeichen, Tabulatoren und Zeilenvorschübe am String-Ende

Beschreibung:

string chop ( string str)

Gibt die in str enthaltene Zeichenkette ohne evtl. vorhandene Leerzeichen, Tabulatoren oder Zeilenvorschübe am String-Ende zurück.

Beispiel 1. chop()-Beispiel:

$string = "10 Leerzeichen am String-Ende          ";
echo chop($string)."?";

// Die Ausgabe lautet:
10 Leerzeichen am String-Ende?

Anmerkung: chop() unterscheidet sich von der Perl-Funktion chop(), die das letzte Zeichen eines Strings entfernt.

Siehe auch trim(), ltrim() und rtrim().

User Contributed Notes
chop
add a note about notes
bernard.SPAM@mindfiredesign.SPAM.co.uk
21-Jan-2002 07:23

To get a perl style chop():
$foo = "bar";
$foo = substr("$foo", 0, -1);
echo $foo;

//returns "fo" (removes last character)

weevil44@hotmail.com
31-Jan-2002 09:25

Actually, it returns "ba", but you get the point.

cthulhu1329@yahoo.com
23-May-2002 05:03

This actually looks like it mimics the perl function chomp.

thouartjay@hotmail.com
31-May-2002 06:16

Correction...the above example is similar to chop, not chomp.  Below is an
example of chomp.

$mystr1 = "This is my string\n";

     // Similar to chomp.  Removes newline at end of string
     // if and only if newline character is at the end.
$mystr1 = preg_replace("/\n$/", "", $mystr1);

add a note about notes
previousbin2hexchrnext
Last updated: Thu, 25 Jul 2002
show source | credits | stats | mirror sites:  
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: nexen.net
Last updated: Sun Aug 11 04:33:03 2002 CEST