Jump to content

[SOLVED] keep getting "Cannot use a scalar value as an array"


lj11

Recommended Posts

I am trying to add a value to $cells[r2] array:

<?php
$cells=array("r1=>array("A","B"), "r2"=>array(1, 2, 3, 4));
print_r (cells['r2']);
$cells['r2'][]=5;        \\ <---- THIS IS WHATS WRONG??
print_r (cells['r2']);
?>

I run this, but always get:

Array ( [r1] => Array ( [0] => A [1] => B ) [r2] => [0] => 1 [1] => 2 [2] => 3 [3] => 4 )
Warning: Cannot use a scalar value as an array in ... on line 3
Array ( [r1] => Array ( [0] => A [1] => B ) [r2] => [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) 

 

plz help  ???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.