Need help on substr function
Moderator: General Moderators
Need help on substr function
Hello Guys,
Just wondering how I can make the substr value changes when submit into mysql.
something like:
someone typed A123456 on a blank field and submit into mysql.the Value will only display 123456 on mysql
Thanks a lot
Just wondering how I can make the substr value changes when submit into mysql.
something like:
someone typed A123456 on a blank field and submit into mysql.the Value will only display 123456 on mysql
Thanks a lot
Re: Need help on substr function
Is it always a single "A"?
Re: Need help on substr function
Yes, always start with "A"
Re: Need help on substr function
Use the ltrim() function.
Re: Need help on substr function
something like:
#
<?php
#
substr=ltrim($sn,0,A)
#
?>
#
<?php
#
substr=ltrim($sn,0,A)
#
?>
Re: Need help on substr function
Without looking at the manual, I'm pretty sure you only need two parameters, the string and the characters to remove. The 0 doesn't need to be there.
EDIT: The A needs to be in quotes.
EDIT: The A needs to be in quotes.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Need help on substr function
Code: Select all
$sn = ltrim($sn,0,'A');
// or
$sn = substr($sn,1);(#10850)
Re: Need help on substr function
I'm pretty sure ltrim only accepts 2 parameters.
Code: Select all
$sn = ltrim($sn, 'A');
Re: Need help on substr function
Issue Resolved, working perfect, Thanks a lot guysastions wrote:I'm pretty sure ltrim only accepts 2 parameters.
Code: Select all
$sn = ltrim($sn, 'A');
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Need help on substr function
For the record, there is a rtrim() and trim function as well, that work pretty much the same way.