Recent Posts
- (02/24) Calling an Element from a Helper TAGS:CakephpWeb ProgrammingUsageTutorialExample
- (10/14) Forcing A Single Join in CakePHP PaginationTAGS:CakephpCakephp 13DatabaseErrorsHabtmMysqlMssqlWeb ProgrammingUsage
- (08/11) Inserting NOW() into MySQL Using CakePHPTAGS:CakephpDatabaseMysqlMssqlWeb ProgrammingUsage
- (08/07) Best PaginateCount for CakePHP - with Group By SupportTAGS:CakephpBehaviorsWeb ProgrammingUsageDatabaseExampleMysqlHabtmHack
- (04/03) CakePHP Error Messages Not Showing on FormTAGS:CakephpCakephp 13Web ProgrammingErrorsUsage
- (02/06) Sorting Paginated Results Using a Related Model Field in CakePHPTAGS:CakephpWeb ProgrammingUsageExample
- (11/02) Changing CakePHP's Model useTable on the FlyTAGS:CakephpWeb ProgrammingMysqlDatabaseExampleTutorial
- (10/18) The Funniest Error Message Ever - Thank You EclipseTAGS:EclipseWeb ProgrammingErrorsHumorWindowsUsageSoftwarePhpCakephp
Subscribe to my feed
MainelyDesign.com Blog
2 Neat Little PHP Tricks
Posted on 03/16/2010 at 04:15 pm by Kevin Wentworth
Viewed 2,130 times | 0 comments
In writing a function to validate bank routing numbers, I came across two simple techniques, that I know I will need to use again:
PHP Trick 1: Remove All Characters Except Numbers from a String
A simple little regex does the trick:
PHP Trick 2: Loop Through a String Character by Character
Setting two variables in a for loop does the trick (that could be trick number 3...):
- echo $routingNumber[$i]; //access to each character in a string
- }
Cheers,
-Kevin Wentworth
Tags for 2 Neat Little PHP Tricks
Php | Example | Tutorial | Web Programming
