Thursday, June 25, 2009

Foreach equivalent in javascript

foreach function in PHP is very nice and easy to use. I was searching for equivalent in javascritp and there are two possibilities.

1. without jquery:


var new_array = new Array();
new_array[0] = 'foo';
new_array[1] = 'bar';

for (var key in new_array)
{
alert(new_array[key]);
}


2. using jquery


var new_array = new Array();
new_array[0] = 'foo';
new_array[1] = 'bar';

$.each(new_array, function(key, value)
{
alert(key + '=>' + value);
});


if you now another option using some other framework, please add it to discussion, thanks

Tuesday, October 21, 2008

Debuging php using vertrigo server and xdebug in eclipse

How to debug php scripts? Answer is easy. Here are few steps, how I have set it.

platform : windows
used software:

Few easy steps, how to set it
  1. download,  install and run vertrigo server

  2. download eclipse PDT 

  3. download "php_xdebug-2.0.3-5.2.5.dll" to
    "
    C:\Program Files\VertrigoServ\Php\ext\php_xdebug-2.0.3-
    5.2.5.dll"

  4. do NOT enable xdebug via vertrigo>settings>extensions settings

  5. edit "php.ini" saved in "C:\Program Files\VertrigoServ\Php\"  (right click on vertrigo tray icon > config files > php.ini)

    add at the end these lines :

    [xdebug]
    zend_extension_ts ="C:\Program Files\VertrigoServ\Php\ext\php_xdebug-2.0.3-5.2.5.dll"
    xdebug.remote_autostart=on
    xdebug.remote_enable=on
    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=9000
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.idekey=ECLIPSE_XDEBUG

    you need to turn off Zend optimizer (coment following lines):

    [Zend]
    zend_optimizer.optimization_level=15
    zend_extension_ts="C:\Program Files\VertrigoServ\Zend\ZendExtensionManager.dll"
    zend_extension_manager.optimizer_ts="C:\Program Files\VertrigoServ\Zend\Optimizer-3.3.0"

    like this:

    [Zend]
    zend_optimizer.optimization_level=15
    ;zend_extension_ts="C:\Program Files\VertrigoServ\Zend\ZendExtensionManager.dll"
    ;zend_extension_manager.optimizer_ts="C:\Program Files\VertrigoServ\Zend\Optimizer-3.3.0"

  6. find line "memory_limit = 8M" in "php.ini"
    change it to "
    memory_limit = 12M"   

  7. restart vertrigo (right click on tray icon > server > restart)