User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 429,841 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,818 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting

PHP Split function

Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: PHP Split function

  #2  
May 15th, 2008
If "LLL" and "LLNNNN" are the 'standard' format, then you can use strlen to check the string length. If string length is 3, then its usertype1. If its 6, the usertype is 2. Well, this is the simplest way. But if you want to thoroughly check, you can explode the variable into an array, (so the array will be $arr[0]="L"; $arr[1]="L"; $arr[2]="L"; and so on ). Then foreach array element, check if its a character or a number. If the character count is 3 and number count is 0, then the usertype is 1. If character count is 2 and number count is 4, then its usertype2.
It really depends on what logic you want to use in your script.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
All times are GMT -4. The time now is 6:30 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC