anuradhu Posted May 30, 2011 Share Posted May 30, 2011 Could someone here explain me the reason for this error in detail..... FYI - i am just more than a fresher in PHP..... Fatal error: Cannot use string offset as an array Quote Link to comment https://forums.phpfreaks.com/topic/237838-array-offset/ Share on other sites More sharing options...
btherl Posted May 30, 2011 Share Posted May 30, 2011 Can you post the code that gave you that error? Quote Link to comment https://forums.phpfreaks.com/topic/237838-array-offset/#findComment-1222190 Share on other sites More sharing options...
anuradhu Posted May 30, 2011 Author Share Posted May 30, 2011 Here is the code if ($comp -> pvc[$real_bas_id]['name']!="") continue; $tpl -> setVariable(array( 'BAS' => $real_bas_info['name'], 'BAS_ID'=> $real_bas_id, )); and here is what i see when i try to dump the REAL_BAS_ID array array(23) { [7]=> array(1) { ["name"]=> string(11) "value" } [14]=> array(1) { ["name"]=> string(12) "value" } [23]=> array(1) { ["name"]=> string(13) "value" } [1]=> array(1) { ["name"]=> string(17) "value" } [20]=> array(1) { ["name"]=> string(18) "value" } [6]=> array(1) { ["name"]=> string(15) "value" } [13]=> array(1) { ["name"]=> string(16) "value" } [10]=> array(1) { ["name"]=> string(11) "value" } [19]=> array(1) { ["name"]=> string(12) "value" } [9]=> array(1) { ["name"]=> string(6) "value" } [17]=> array(1) { ["name"]=> string(7) "value" } [3]=> array(1) { ["name"]=> string(9) "value" } [21]=> array(1) { ["name"]=> string(10) "value" } [8]=> array(1) { ["name"]=> string(10) "value" } [15]=> array(1) { ["name"]=> string(11) "value" } [4]=> array(1) { ["name"]=> string( "value" } [16]=> array(1) { ["name"]=> string(9) "value" } [5]=> array(1) { ["name"]=> string(7) "value } [12]=> array(1) { ["name"]=> string( "value" } [22]=> array(1) { ["name"]=> string(9) "value" } [11]=> array(1) { ["name"]=> string(4) "value" } [2]=> array(1) { ["name"]=> string(7) "value" } [18]=> array(1) { ["name"]=> string( "value" } } Quote Link to comment https://forums.phpfreaks.com/topic/237838-array-offset/#findComment-1222194 Share on other sites More sharing options...
btherl Posted May 30, 2011 Share Posted May 30, 2011 What is in $comp->pvc ? If it is not an array, then that is probably the cause of the error. The error is often caused like this: $foo = 'bar'; print $foo[0]; # OK, treating a string as a 1 level array gives you a string offset instead print $foo[0][0]; # Error! Can't treat a string as a 2 level array Quote Link to comment https://forums.phpfreaks.com/topic/237838-array-offset/#findComment-1222197 Share on other sites More sharing options...
anuradhu Posted May 30, 2011 Author Share Posted May 30, 2011 Wow !! thanks a ton !! The problem is exactly that - comp->pvc is string(5) "EMPTY" Quote Link to comment https://forums.phpfreaks.com/topic/237838-array-offset/#findComment-1222199 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.