Re: [PHP] first letter
Ahmed Abdel-Aliem wrote: hi if i have for example this variable $name = John; how can i echo the first letter only so the result on the browser will be J can anyone help ? $name[0] -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] first letter
Not sure if it's deprecated or not, but you can reference it as an array: echo $name[0]; or the more accepted method: echo substr($name,0,1); From: Ahmed Abdel-Aliem [EMAIL PROTECTED] Date: 2004/12/20 Mon PM 12:59:49 EST To: [EMAIL PROTECTED] Subject: [PHP] first letter hi if i have for example this variable $name = John; how can i echo the first letter only so the result on the browser will be J can anyone help ? -- Ahmed Abdel-Aliem www.ApexScript.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] first letter
if i have for example this variable $name = John; how can i echo the first letter only so the result on the browser will be J echo $name[0]; You could also use the substr() function. Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] first letter
[begin untested code] $name = 'John'; echo substr($fname,0,1); [end untested code] That will print the first letter of the variable $name. substr(string,int start, int length); int length is optional. On Mon, 20 Dec 2004 19:59:49 +0200, Ahmed Abdel-Aliem [EMAIL PROTECTED] wrote: hi if i have for example this variable $name = John; how can i echo the first letter only so the result on the browser will be J can anyone help ? -- Ahmed Abdel-Aliem www.ApexScript.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] first letter
echo $name{0}; See http://us2.php.net/manual/en/function.substr.php for more... -Original Message- From: Ahmed Abdel-Aliem [mailto:[EMAIL PROTECTED] Sent: Monday, December 20, 2004 1:00 PM To: [EMAIL PROTECTED] Subject: [PHP] first letter hi if i have for example this variable $name = John; how can i echo the first letter only so the result on the browser will be J can anyone help ? -- Ahmed Abdel-Aliem www.ApexScript.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] first letter
$name = John; echo $name{0}; you can also look into substr() - Original Message - From: Ahmed Abdel-Aliem [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 20, 2004 12:59 PM Subject: [PHP] first letter hi if i have for example this variable $name = John; how can i echo the first letter only so the result on the browser will be J can anyone help ? -- Ahmed Abdel-Aliem www.ApexScript.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] first letter
Ahmed Abdel-Aliem wrote: hi if i have for example this variable $name = John; how can i echo the first letter only so the result on the browser will be J can anyone help ? echo $name{0}; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] first letter
echo $name[0]; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] first letter
$name = John; how can i echo the first letter only so the result on the browser will be J echo $name{0}; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php