sending array as json to php script : returns empty array
===

i'm trying to send a form inputs as array to a php script 

    function submit_form(){
    	var arr  =  [];
    	var key, val ;
    	$('#form input').each(function(){
    		
    		key = $(this).attr('id');
    		val = $(this).val();
    		arr[key] = val;
    	 	
    	})
	    alert(arr['username']); // check to see if array is not empty

        var jsondata =  JSON.stringify(arr); 
    		
    	$.post(base_url+'profile/edit_profile/<?php echo $profile_username; ?>' , {data : jsondata }, function(){
    	})
    }


on the php script 

    $data =  json_decode($this->input->post('data'));
    var_dump($data);
    exit;

and here is the result 

    array (size=0)
      empty