I have an Oracle database which serves as an array of ~70 values. I am trying to find the most efficient code to pass each cell value to a variable, preferebly coded in PHP.
Example:
Cell1 Cell2 Cell3 Cell4 ... Cell70
Pass each cell 1-70 to a variable named after that cell:
($CELL1, $CELL2, $CELL3, $CELL4 ... $CELL70)
It'd be FAR simpler to just use an array:
$arr = oci_fetch_array(...);
so you don't pollute the namespace with a bunch of (mostly) useless variables.
If you INSIST on going this route, then you could try:
list($cell1, $cell2, $cell3, ...., $cellWayTooManyCells) = oci_fetch_array(...);
Or
$arr = oci_fetch_assoc(...);
extract($arr);
I can think of no practical reason to use multiple variables over an array, but you could in theory use variable variables:
for ($i = 0; $i < count($arr); $i++) {
${"Cell" + $i} = $arr[$i];
}
Instead it would be much simpler to just use $arr["Cell1"]
in spots where you may want to use $Cell1
.