শুরু থেকে এক্সট্রা হোয়াইটস্পেস সরাতে PHP-এ ltrim() ব্যবহার করুন। ধরুন, আমাদের ভেরিয়েবলটি হলো—
$value = " Hello, welcome to PHP Tutorial ";
আমরা চাই বাম দিক থেকে হোয়াইটস্পেস নেই এমন আউটপুট—
Hello, welcome to PHP Tutorial
উদাহরণ
<!DOCTYPE html> <html> <body> <?php $value = " Hello, welcome to PHP Tutorial "; print_r("The actual value is = " . $value . "<br>"); echo "The actual length is = ", strlen($value), "<br>"; $modifiedValue = ltrim($value); echo "After removing extra whitespace from beginning = ", strlen($modifiedValue), "<br>"; echo "The result is = " . $modifiedValue; ?> </body> </html>আউটপুট
এটি নিচের আউটপুট দেবে—
The actual value is = Hello, welcome to PHP Tutorial The actual length is = 34 After removing extra whitespace from beginning = 32 The result is = Hello, welcome to PHP Tutorial