Back soon – Work has me busy

Just a quick note – I see a lot of people have come to this site, based on many theological and technical search queries through search providers, and I apologize for the delay in new posts.

I’ve got quite a few theological articles, Photoshop techniques, PHP nifties, Flash hacks, and CSS tricks to share, and once I’ve finished with AS2.0 (the site I’m currently building for work), I will be thrilled to share what I have learned during that process.  All the new material I’ve been developing is outlined in one of my Moleskines (no IP, of course, don’t be ridiculous 8]  ), as are the theological passages in another Moleskine.

Now, if you’ll excuse me, I have some PHP to get back to…

Actually, I should probably go to sleep… =/

Tagged with:
 

Whew that’s a long title.

Basically, i have a string that I have hashed out – for storage in a database.  It looks like this:

Name#123#345#456#678#789#

Now, the problem is – I need to get the first value from this string – before the first ‘#’ – but it could be of completely variable length.  This poses a problem – if all sections were of a set length this would be far easier.  Not to mention that the string as a whole could have a variable number of segments.

The solution – as I have found – is to use a nasty looking string in PHP to parse it out.  For the sake of this example, let’s call our nasty string up there $toParse.

<?php $name = substr($toParse, 0, strpos($toParse, "#")); ?>

This will, in turn, set the variable $name to ‘Name’.

Now – let’s say that I need to actually parse all of these sections.  This is also quite easy to accomplish.. We just execute this, plus one more bit – recursively.

<?php
$workingString = $toParse;
//While we still have some string left
while ($workingString != ""){
$name = substr($workingString, 0, strpos($workingString, "#"));
//Remove the previous entry and the previous hash
$workingString = substr($workingString, (strpos($workingString, "#")+1));
//Do whatever you intend to do with your $name result
}
?>

And… That’s pretty much it.

Tagged with:
 

Remember those of you who found this site purely by accident – this site is mostly for my own use.

That said – here for my reference – the Bash commands that I end up using most often with the php exec(); command or in the shell – here in case I forget them… again. (I can remember what everyone ate at my last job interview, yet I have trouble remembering simple shell commands… odd.)

Use sudo as needed!
(more…)

Tagged with:
 
Pro Palma Deus Unus