במדריך זה נלמד איך להמיר את האות הראשונה של מחרוזת לאותיות גדולות ב-PHP.
פונקציות בשימוש:
()ucfirst
()strtolower
ניתן להשתמש בפונקציה ()ucfirst כדי לשנות את התו הראשון של מחרוזת לאותיות גדולות.
לחלופין, ניתן יכול להשתמש בפונקציה ()strtolower בשילוב עם הפונקציה ()ucfirst אם אתה רוצה להפוך רק את האות הראשונה של המחרוזת לאותיות גדולות ואת שאר המחרוזת לאותיות קטנות.
בפניכם דוגמא על אופן הביצוע:
<?php
$str1 = 'spread love everywhere you go. let no one ever come to you without leaving happier. -mother teresa';
echo ucfirst($str1);
echo "<br>";
$str2 = 'the Color of the Sky is Blue.';
echo ucfirst(strtolower($str2));
?>
פלט:
Spread love everywhere you go. let no one ever come to you without leaving happier. -mother teresa
The color of the sky is blue.