Re: Converting a string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You're best off using an array that matches human readable form to field name as someone else suggested earlier. Form names for basic fields like this should be standardized such that auto form fillers (aka Google toolbar) are able to work. They won't know that your field named "hmnrdble_F-irst_N-ame" equates to a first name field. Skip the dastardly regexp and keep it simple.

On the posted to page populate the array with boolean values as you do you boundary checking. If you fail, then save it to session, redirect back to the form, read the array from session, and you have access to ALL fields that failed, so you can not only have a message at top, but the ability to mark each field with a style or some such to visually draw the user to what they need to fix.

-Myk OLeary
myko@xxxxxxxxxxxxxx
BLOG: http://www.blueneedle.com/wordpress/?bnphplists

On Mar 17, 2006, at 11:21 AM, Jay Blanchard wrote:

[snip]
	Then you should change the name of the field.  Seriously, what
do you
expect the script to do, exactly? and once you know the answer, what
would you do to achieve that?  Put that (emphasis to the second
question) in words and someone might be able to help you.
[/snip]

I expect that I can take a string, like 'psFirstName' and change it to
'First Name'. that way I don't have to worry about what some web
designer named his fields, I can turn them into human readable strings
without having to manually create a new array.

So far I have this

$newKey = preg_split("/([A-Z])/", substr($key, 2), -1,
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

Which returns;

Array
(
    [0] => F
    [1] => irst
    [2] => N
    [3] => ame
)

--
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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux