I'm fairly new to PHP and having a problem with an array. I have just set up my function with an array in it. Everything is working fine except when I call my array outside the function it seems nothing is inside, (my last for loop prints nothing out) the error displays "Notice: Undefined offset: for each number".
Here is the code:
$col_num = array();
// `getcoleachrow()`: function to get each data in each column row
function getcoleachrow ($col = array(), $value, $html){
// 220 cells in the table
for ($value=$value;$value<220;$value+=11){
//gets the data from a cell then turn it to text and stores it in an array selected
array_push($col, $html->find('td', $value)->plaintext);
}
// 20 rows and 20 data from the table in an array
for ($rows = 0;$rows<=19;$rows++) {
//print out array
echo $col[$rows];
}
} // getcoleachrow
// Call the `getcoleachrow()` function
getcoleachrow($col_num, $pos, $html);
//getcoleachrow($col_team, $team);
// Goes through every row
for($row = 0;$row<=19;$row++){
echo $col_num[$row];
}
The last for loop is empty but the getcoleachrow($col_num, $pos, $html);
prints out every I want.
$col
from the function or have it pass by reference.