UYalcin UYalcin - 2 years ago 87
PHP Question

Using Arrays in PHP (for inexperienced programmer)

I have a javascript code that calculates and organizes some variables through multiple functions, however I was informed for this application my code needs to run on server side, therefore I need to rewrite in PHP. As someone who knows nothing about PHP, I was relieved when I saw that using if,for etc was just like JS.

However I am at complete loss about how to use arrays in PHP. The tutorials on internet are all for html/PHP context, whereas I just want to have code that calculates some variables and store them in arrays before passing them on to database.

If someone would be kind enough to translate below JS code portion into PHP friendly version, then I can fix rest of my code based on that example.

example of what I have in JS:

var my_array[];
var my_multiarray[];
var i,o;



Answer Source
$my_array = array(); //array declaration php 
$my_multiarray = array();
$i,$o; // this can also be declared directly in the loop php does not require predeclaration

for($i=0; $i<10; $i++){

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download