Walking array the PHP way, A look into array_walk()

February 9, 2012 | Miscellaneous, Web Development

If you’ve been developing with PHP for a while, you’ve probably come across this situation in the past:

<?php
foreach ($somearray as &$element) {
$element = some_function($element);
}

It’s a common sight: taking an array and running (well, walking) its elements through a particular function. Luckily, PHP provides a simple yet powerful function to overcome this: array_walk().

Read the full story…

 

How to convert currencies using cURl and Google + PHP

February 7, 2012 | Miscellaneous, Web Development

currency

Converting currency would not have been a big deal if the exchange rate was fixed. But given that the exchange rate changes every other second, we use services from one of the trusted sites to show  the latest exchange rates. Here we take help of Google to find the latest currency exchange rate and convert the currency to required currency. I hope this piece of code helps you.

Read the full story…

 

PHP Arrays: Array Functions and Multidimensional Arrays

January 26, 2012 | Miscellaneous, Web Development

The difference between one-dimensional and multidimensional arrays is a simple one: a multidimensional array is a simple array that has simple arrays as elements, rather than strings or scalar variables.

Building a Multidimensional Array

Here is how our $arrBooks example from last week’s article can be expanded into a multidimensional array: Read the full story…

 
WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera