[Resolved] help forming&selecting info from a multidim a
Posted: Sun Apr 02, 2006 11:11 am
feyd | Please use
I build the array as so:
The $rowsTrans is selected from the text file earlier and is returning the correct result.
The output of print_r($transTable Array) is:
Now to select the information from the array I'm doing this:
Its output is:
Why is it returning 0? I know I'm in $transTableArray[0][0] but its value should be 3...
If anyone could help me at all it would be appriciated, I'm on AIM as elmcitizen as well.
Thanks Again!
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hello all, i'm having some trouble selecting information from a multidimensional array.
I'm reading in the array information from a text file, the information is formatted as so:Code: Select all
3 1
1 2
4 1
4 1
4 1Code: Select all
//get Transition Table
for ($counter = 0; $counter < $rowsTrans; $counter++)
{
$tableTrans = fgets($fp);
$tableTrans = trim($tableTrans);
//split string into array
$TransTable = explode(" ", $tableTrans);
//array into multidimensional array
$transTableArray[$counter] = $TransTable;
print_r($TransTable);
echo "<br>";
}
print_r($transTableArray);The output of print_r($transTable Array) is:
Code: Select all
Array ( [0] => Array ( [0] => 3 [1] => 1 ) [1] => Array ( [0] => 1 [1] => 2 ) [2] => Array ( [0] => 4 [1] => 1 ) [3] => Array ( [0] => 4 [1] => 1 ) [4] => Array ( [0] => 4 [1] => 1 ) )Code: Select all
//get value from Transitional Table
$column = current( $usrStringArray);
echo "Column: $column <br>";
$row = $currentState;
echo "Row: $row <br>";
$currentState = $transTableArray[$row][$column];
echo "Test: $transTableArray[$row][$column]<br>";
echo "Results from Trans Table Inquiry (last Char): $currentState <br>";Code: Select all
Column: 0
Row: 0
Test: [0]If anyone could help me at all it would be appriciated, I'm on AIM as elmcitizen as well.
Thanks Again!
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]