By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,948 Members | 1,595 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,948 IT Pros & Developers. It's quick & easy.

how can i restrict the first character in PHP string?

P: 28
like user have to type "A" for the first character in the blank bar,so how can i restrict the "A" for the first character in php string?

Thank you
Sep 21 '07 #1
Share this Question
Share on Google+
4 Replies


pbmods
Expert 5K+
P: 5,821
Heya, Cyberlei. Welcome to TSDN!

Something like this?
Expand|Select|Wrap|Line Numbers
  1. $str[0] = 'A';
  2.  
Sep 21 '07 #2

P: 28
Heya, Cyberlei. Welcome to TSDN!

Something like this?
Expand|Select|Wrap|Line Numbers
  1. $str[0] = 'A';
  2.  
something like this:
Expand|Select|Wrap|Line Numbers
  1.  if($sn<>"" $str[0] = 'A';)
  2.     {
  3.         $q = "update remotestatus set step=8 where ip='$ip'";
  4.         mysql_query($q)or die(mysql_error()) ;
  5.         $step=8;
  6.     }
  7.     else
  8.     $message="Number Must Be Start With A";
  9.         }
  10.  
Sep 21 '07 #3

bergy
P: 89
This should work

[php]
if(substr($str, 0, 1) == "A"){
//string okay
}else{
//string not okay :(
}
[/php]
Sep 22 '07 #4

P: 28
This should work

[php]
if(substr($str, 0, 1) == "A"){
//string okay
}else{
//string not okay :(
}
[/php]

Working well.

Thanks a lot
Oct 11 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.