PHP chop() function

Example

Remove characters from the end of the string:

<?php
$str = "Hello World!";
echo $str . "<br>";
echo chop($str,"World!");
?>

ການດຳເນີນການ

Definition and Usage

chop() function removes whitespace characters or predefined characters from the end of the string.

Syntax

chop(string,charlist)
Parameter ອະທິບາຍ
string ສະເພາະ. ພົບກັບວ່າຈະກວດກາວິກາການດັ່ງກ່າວ:
charlist

ທາງລວມ. ພົບກັບວ່າຈະລົບຕົວການສະແດງສັນຍານຊີ້ນຳຂອງວິກາການດັ່ງກ່າວ:

ຖ້າ charlist ຖ້າປະເພດນັ້ນເປັນສິບຄ່າວ່າ, ລົບຕົວການສະແດງສັນຍານຊີ້ນຳຂອງວິກາການດັ່ງກ່າວ:

  • "\0" - NULL
  • "\t" - Tab
  • "\n" - Newline
  • "\x0B" - Vertical tab
  • "\r" - Carriage return
  • " " - Space

ຂໍ້ມູນດ້ານເຕັກນິກ

ຄຳຕອບກັບ: ຮັບຄືນຂັ້ນຕົວທີ່ໄດ້ດັດແປງ.
PHP Version: 4+
ບັນທຶກການປັບປຸງ: ໃນ PHP 4.1.0, ໄດ້ປັບປຸງ charlist ປະເພດ

ຕົວຢ່າງຫຼາຍກວ່າ

ຕົວຢ່າງ 1

ລົບຕົວການສະແດງສັນຍານຊີ້ນຳຂອງວິກາການ (\n):

<?php
$str = "Hello World!\n\n";
echo $str;
echo chop($str);
?>

ການສະແດງ HTML ຂອງວິກາການດັ່ງກ່າວຢູ່ບຸກຄົນນັ້ນ (ກວດຄຳນວຍໄອ້):

<!DOCTYPE html>
<html>
<body>
Hello World!
Hello World!
</body>
</html>

ການສະແດງສັນຍານຂອງວິກາການດັ່ງກ່າວຢູ່ບຸກຄົນນັ້ນ:

Hello World! Hello World!

ການດຳເນີນການ