PHP में एक स्ट्रिंग के पहले अक्षर को हटाने के लिए, कोड इस प्रकार है-
उदाहरण
<?php $str = "Test"; echo "Before removing the first character = ".$str; $res = substr($str, 1); echo "\nAfter removing the first character = ".$res; ?>
आउटपुट
यह निम्नलिखित आउटपुट देगा -
Before removing the first character = Test After removing the first character = est
उदाहरण
आइए अब एक और उदाहरण देखें
<?php $str = "Demo"; echo "Before removing the first character = ".$str; $res = ltrim($str, 'D'); echo "\nAfter removing the first character = ".$res; ?>
आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा-
Before removing the first character = Demo After removing the first character = emo