Home » Archive

Articles tagged with: array

jQuery »

[22 Jan 2010 | No Comment | 270 views]

It’s very easy to print array and object with jQuery. You can do it with jQuery.each() function. The jQuery.each() function can be used to iterate over any collection, whether it is a map (JavaScript object) or an array.
Here is the javascript code to print array or object:

jQuery(document).ready(function(){
var arr = [ "earth", "mars", "jupiter", "saturn", "venus" ];
var obj = { one:"earth", two:"mars", three:"jupiter", four:"saturn", five:"venus" };

jQuery.each(arr, function(i, val) {
$("#arrData").append(i + " : " + val + "<br/>");
});

jQuery.each(obj, function(i, val) {
$("#objData").append(i + " => " + val + …

Javascript »

[8 Jan 2010 | 2 Comments | 72 views]

It’s a real headache when you have to work on objects and arrays in Javascript. It would be lot easier to detect elements of the Javascript objects/arrays if we have print_r function in Javascript as we have in PHP.
I googled the web and have found a very efficient print_r Javascript function. This has helped me a lot in my projects. Here is the code:-

Javascript, PHP »

[23 Oct 2009 | No Comment | 60 views]

I had to work on multi-dimensional array with javascript and php. I had a multi-dimensional array in php. I had to load it into javascript array and then populate the html selection list.
The challenge for me was to create multi-dimensional array in javascript and populate selection list with for loop in javascript.

MySQL, PHP »

[9 Dec 2007 | No Comment | 18 views]

Problem:
Concatenate and fetch data from two fields of database and then break it again.
Solution: