Archive for tag Php
September 30, 2009 at 10:03 PM
· Tagged with php
After playing around with frameworks such as Ruby on Rails, CakePHP, CodeIgniter, and many others - I came to like the templating systems they used. They were quite fast, efficient, and importantly - very easy to use. However, with a current task I've been given, I've realised that there are some of us out there who aren't using these frameworks, dislike templating engines like Smarty, but need a good, robust templating system. Enter PHLite (pronounced flight).
Would love to hear people's comments about this!
May 12, 2009 at 04:51 PM · Posted under Projects
· Tagged with php
Integrating the Auspost eParcel with your own ecommerce website may sound easy, but add to that outdated or incorrect documentation and site failures, and you run into a few lessons.
May 10, 2009 at 05:05 PM · Posted under Blog
· Tagged with php
It's fairly general knowledge in PHP that if you want the first item of an array, you can use array_shift. However, this also removes the element from the array and this may not be the intended functionality of the developer. Introducing: array_first.
April 14, 2009 at 03:28 PM · Posted under Blog
· Tagged with php
After having dealt with some directory-creation lately based on user input, I decided to safe-guard the creation of directories with the following function: directorize().
December 09, 2008 at 10:30 AM · Posted under Blog
· Tagged with php
After delving around in ruby for a little and finding the magic that is the Array.collect method, I decided to write one for PHP, considering how much I use it in Ruby. Hopefully others will find some use in this function.
<?php
function array_collect($array, $params)
{
$return = array();
if (!is_array($params)) {
$params = array($params);
}
foreach ($array as $record) {
$rec_ret = array();
foreach ($params as $search_term) {
if (array_key_exists($search_term, $record)) {
$rec_ret[$search_term] = $record[$search_term];
}
}
if (count($rec_ret) > 0) {
$return[] = $rec_ret;
}
}
return $return;
}
?>
Basically, what this allows us to do is extract information from an array and have it stored in another array. For example, we may only want a few select fields as a subset of data, we could do this by doing:
$records = array(array('a' => 'y', 'b' => 'z', 'c' => 'e'), array('a' => 'x', 'b' => 'w', 'c' => 'f'));
$subset1 = array_collect($records, 'a'); // $subset1 will be: array(array('a' => 'y'), array('a' => 'x'));
$subset2 = array_collect($records, array('a', 'c')); // $subset2 will be: array(array('a' => 'y', 'c' => 'e'), array('a' => 'x', 'c' => 'f'));
October 23, 2008 at 11:29 AM · Posted under Blog
· Tagged with php
It's a rather convoluted way of getting a blog going, but in an attempt to learn more about web infrastructure and environments, I now own my own server, configured it for web requests and setup Ruby on Rails, along with related software, all just to get Mephisto running. And I'm not done there. This box will now be used for all my personal projects, including running as a UAT/Systest box for my more commercial projects.
This is also my first blog post here and will most certainly not be the last, as I write about my frustrations and victories in learning new and wonderful technologies (and some old), as well as tutorials and articles regarding PHP, Ruby, Rails and setting up a web server.