I got a PHP array which looks like that:
array(3) {
[0] => array(3) {
["Row"] => string(1) "1"
["Col"] => string(1) "1"
["Value"] => string(4) "lbl1"
}
[1] => array(3) {
["Row"] => string(1) "2"
["Col"] => string(1) "1"
["Value"] => string(4) "lbl2"
}
[2] => array(3) {
["Row"] => string(1) "3"
["Col"] => string(1) "1"
["Value"] => string(4) "lbl3"
}
}
I know that every pair "Row" and "Col" is different from the others. I can't change the way I'm creating the array.
Can I somehow access the array kinda like a hash table like this: arr[Row => 0][Col => 0]
and get the value which is in Row 0 and Col 0?
If I understand your question well, you would need to reformat you array in order to access it like so: $array[1][1]
to get Value
of lbl1
.
Try this where $array
is your initial Array
.
<?php
$return = array();
foreach($array as $value)
$return[$value['Row']][$value['Col']] = $value['Value'];
var_dump($return[1][1]); // outputs "lbl1"
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다