1
i want to store 100000 nos in array so that i have declared my varibles as double but getting following error

PHP Warning:  Cannot use a scalar value as an array in solution.php 

i read some posts and they according to them you have to declare array like

$l_arr= array(); 
 $l_arr[]=0;

to remove the scalar error,how can i store big numbers in varible,guyz do you have any alternative method.how can we declare double array or how can we increase size of it.

/* Enter your code here. Read input from STDIN. Print output to STDOUT */

$handle = fopen ("php://stdin","r");
fscanf($handle,"%d",$n);

    $i=0;
    $l_arr= array();
    $r_arr= array();
    $in= array();
    $map= array();

    $l_arr[]=0;
    $r_arr[]=0;
    settype($arr_temp,'double');
    settype($l_arr,'double');
    settype($i,'double');
    settype($r_arr,'double');
    settype($in,'double');
    settype($map,'double');
     for($i=0;$i<$n;$i++)
    {
         $arr_temp = fgets($handle);
         $l_arr[$i]= trim(preg_replace("/[0-9,.]/", "", $arr_temp));
         $l_arr[$i]=trim(preg_replace("/[^0-9,.]/", "", $arr_temp));
    }
    for($i=0;$i<$n;$i++)
    {
        $arr_temp = fgets($handle);
        $in[$i]=trim($arr_temp);
    }
    for($i=0;$i<$n;$i++)
    {
       $map[$l_arr[$i]]=$r_arr[$i];
    }
    for($i=0;$i<sizeof($in);$i++)
    {
       if($map[$in[$i]]!=NULL)
       {
          echo $in[$i]."=".$map[$in[$i]]."\n";
       }
       else
       {
          echo "Not found \n";
       }
    }

?> 
  • Possible duplicate of [PHP - cannot use a scalar as an array warning](https://stackoverflow.com/questions/6019853/php-cannot-use-a-scalar-as-an-array-warning) – Bilal Ahmed Jul 14 '17 at 10:25

1 Answers1

0

error in the way i am assigning values to array