how to update the php class array values

class Field {
        public $dataFields;

        public function addValue($table,$key,$data){
          print_r($this->dataFields[$table]);
          echo "\ndata: ".$data."\n";
          if(isset($this->dataFields[$table][$key])){
              $this->dataFields[$table][$key]= $data;
              echo "yes\n";
            }
          else echo "no\n";
          print_r($this->dataFields[$table]);

         }

         public function setVariables($con){
            $result = mysqli_query($con,"select * from city limit 1");
            $row=mysqli_fetch_fields($result);
            foreach ($row as $key => $value) {
                $propData[$value->table][$value->name]="";
            }
            $propData["property"]["portalId"]=2;
            $propData["property"]["area"]="delhi";
            $this->dataFields=$propData;
            $this->addValue("property","id","1");
            //print_r($this->dataFields);
        }
    }

as you can see the code I am updating the value of array through function addValue, if the key is set in the dataFields array then it will get updated but in this its not happening when i try to call the function:

addValue(“property”,”id”,”1″); through function xyz()
(see the output below)

it prints the value of $data it prints “yes”.
The class variable dataFields is not getting updated.

Am I doing something wrong here?

    Array
    (
        [id] =>
        [portalId] => 2
        [area] => delhi
    )                                             

    data: 1
    yes
    Array
    (
        [id] =>
        [portalId] => 2
        [area] => delhi
    )


Download how.to.update.the.php.class.array.values.zip
Direct Link


Download


Download how.to.update.the.php.class.array.values.zip
Mediafire


Download


Download how.to.update.the.php.class.array.values.zip
Zippyshare


Download

Both comments and pings are currently closed.

Comments are closed.