PHP

php

PHP Question: Pass By Reference

Tuesday, April 19, 2011 - 13:47

Question

Consider the following:

1
2
3
4
5
6
function doSomething(&$val) {
    $val++;
}
 
$a = 1;
doSomething($a);

What does the variable $a now equal?

Category: 

Number Pair Additions In PHP

Sunday, April 17, 2011 - 00:33

I was helping my son out with his maths homework today and we came across a question that asked him to find some combinations of two numbers that added up to a given number (he is only 6 so this was good maths practice). This got me to thinking about how to calculate all possible ways in which two numbers could be added together to make another number.

Category: 

Automatically Copying The Node Title To The Menu Title In Drupal 6

Wednesday, April 13, 2011 - 17:48

One new feature of Drupal 7 is that any title you give a node will be copied to the menu title field when you create a menu item. I wanted to replicate this functionality in Drupal 6 and so I created a function that did just that. I have used this function a few times in different projects so I'm posting it here.

Category: