Jump to content

[SOLVED] Breaking Strings Up


bdmovies

Recommended Posts

Ok, I know I'm asking stupid questions, but please bear with me, I'm only a baby PHP programmer.

 

I've got a uniqueID for every Summons I input into the DB. The way I'm doing this counter is something like this.

 

QUERY get the last uniqueID

 

Split the unique ID into 2 parts. 1st = 2007 2nd = 00001 (the first part is the current year, the 2nd part, i'm calling the serial#)

 

so now I have

$id_year and $serial

 

If the $id_year  == current year then $serial == $serial +1

 

elseif $id_year < current year then $serial == 1

 

elseif $id_year > current year STOP EVERYTHING, THE COMPUTER DATE IS WRONG

 

implode the $id_year and $serial into $unique_id

 

later on in the code, you insert the unique_id into the next row along with the rest of the information

 

 

Ok, so I know it doesn't look pretty, but I haven't written the code yet. My question is how can I split the 200700000 into 2007 and 00000?

Link to comment
Share on other sites

php actually has a lot of modules that you will never use (like the hypewave functions), but its good to know all the modules so when the day comes you can say oh that could be useful.  Even inside each module there are tons of functions considered useless or so specific they can't be used.  One that comes to mind is the array functions, many of these are over kill and you don't need them beyond the basics, but knowing that php.net has a list of all these you never know when u might use one.  Just the other day I found a use for http://us.php.net/manual/en/function.array-pop.php that saved me a few lines in a pagination display. 

 

Knowing the bare minimal isn't good, the trick is to have a general idea about structure and usage for most things and you can get by very easily.  That and using good structure in coding so you can see errors very easily.

 

I don't ever use OOP so I wouldn't be a help to you.

Link to comment
Share on other sites

Yea, I really enjoy knowing the ins and outs of everything. Although, I'm a self-taught programmer, so knowing all of that is rather difficult, I found it's just a lot of learning as I go. I know the code for the app I'm writing now most likely sucks, but I'm learning, and I'll just sit there and fix what needs to be fixed and re-write what needs to be re-written....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.