Articles Archive for March 2008
Posted: Mar 30 | Filed under: Wordpress
One of the most important thing for a wordpress developer is to know where the user is right now. The wordpress reference has a very important site that shows all the necessary functions to do that.
That links is definetly a must-have-bookmark for every WP developer!
Posted: Mar 29 | Filed under: General
Today I had to convert a multidimensional array and found a very simply solution at PHP.net that I want to share with you.
A multidimensional array is an array that stores arrays. Usually a normal array is easier to handle, that’s why converting the array is a good solution.
That will turn this:
Array
(
[1] => Array
(
[0] => 1
[1] => 2
)
[2] => Array
(
[0] => 3
[1] => 4
)
)
Into this simple array:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
Here’s the very efficient and short code:
function flatten_array($value, $key, &$array) {
if (!is_array($value))
array_push($array,$value);
else
array_walk($value, 'flatten_array', &$array);
}
Then you are able to to use “array_walk”, simply rename $oldarray to the name of your multidimensional array!
$newarray = array();
array_walk($oldarray, 'flatten_array', &$newarray);
Happy converting !
Posted: Mar 29 | Filed under: General
Let’s say you got a table with lots of entries that have the same value and you want to safe each entry in an array even if it’s a “duplicate”, you can do it with a simple SQL query:
$query = $db->query("SELECT * FROM $db->tablename where exists ( SELECT tablerow_name FROM $db->tablename) ") ;
I hope that helps a bit
Posted: Mar 27 | Filed under: Wordpress
A lot of people are sick of the wordpress editor because it will mess up their posts.
Here is the solution that worked for me. I do not say that this will work for anyone. A lot of people don’t want to turn of the Visual Editor to quickly edit their posts, but you will have to.
Turn it off Go to “Users” -> “Your Profile” and uncheck “Use the visual editor when writing”.
Posted: Mar 27 | Filed under: Wordpress
Here’s the code to save the current wordpress tag, if you are on a “tag site”:
<?php $current_tag = single_tag_title(”", false); ?>
Taken from the wordpress reference.
Posted: Mar 27 | Filed under: General
For website developing it is crucial to know your variables. To double check your array values here is the simple code:
echo "<pre>";print_r($array); echo "</pre>";


