chop() फ़ंक्शन
PHP में chop() फ़ंक्शन स्ट्रिंग से व्हाइटस्पेस या अन्य कैरेक्टर्स हटाने के लिए उपयोग किया जाता है। यह rtrim() का एलियास है।
सिंटैक्स
chop(string $string, string $characters = " \n\r\t\v\0"): string
पैरामीटर्स
- string - एस्केप की जाने वाली स्ट्रिंग
- characters - हटाए जाने वाले कैरेक्टर्स निर्दिष्ट करें
रिटर्न वैल्यू
chop() फ़ंक्शन मॉडिफाइड स्ट्रिंग रिटर्न करता है।
उदाहरण 1
<?php $str = "Demo Text!"; echo $str . " "; echo chop($str, "Text!"); ?>
आउटपुट
Demo Text! Demo
उदाहरण 2
<?php $str = "Welcome \nto the \nwebsite \n"; echo $str; echo chop($str); ?>
आउटपुट
Welcome to the website Welcome to the website