pass array from jquery ajax to php and writ the contenute into a file
hello guy i need to parse one array and send it to the php file that will write the contenute into a file

this is the function

	var label = a.text;
	GetEl('emotion-label').innerHTML =  "I'm  " + a.text; 
	
	 $.ajax({
			url:'mehrabian_pad_subset with AB doubles 2d&3D.csv',
			success: function (data){
				//parse ur data
				//you can split into lines using data.split('\n') 
				//use regex functions to effectivley parse
				var new_label = GetEl('emotion-label').innerHTML;
				var label_custom = data.splitCSV();
				
				for (var i=0; i<label_custom.length-1; i++)
				if( label_custom[i][1] == a.text )
				$.post("JS/foo.php", {data: label_custom[i]}, function(result){ alert("test") }, "json");
			}
	});


this is my php file 

    <?php
     $dir = '/var/www/devData/test';
    
     // create new directory with 777 permissions if it does not exist yet
     // owner will be the user/group the PHP script is run under
     if ( !file_exists($dir) ) {
      mkdir ($dir, 0777);
     }
     if (isset($_POST['data'])) {
    		 
             $stringData = $_POST['data'];
             $file = "/var/www/devData/test/ciao.txt"; 
    		 echo $stringData;
    		 echo "ciao";
             $fh = fopen($file, 'w') or die("can't open file");
             fwrite($fh, $stringData);
             fclose($fh); 
     }
     
     
     ?>

Any one know how can i do?
pass array from jquery ajax to php and writ the contenute into a file
===

hello guy i need to parse one array and send it to the php file that will write the contenute into a file

this is the function

	var label = a.text;
	GetEl('emotion-label').innerHTML =  "I'm  " + a.text; 
	
	 $.ajax({
			url:'mehrabian_pad_subset with AB doubles 2d&3D.csv',
			success: function (data){
				//parse ur data
				//you can split into lines using data.split('\n') 
				//use regex functions to effectivley parse
				var new_label = GetEl('emotion-label').innerHTML;
				var label_custom = data.splitCSV();
				
				for (var i=0; i<label_custom.length-1; i++)
				if( label_custom[i][1] == a.text )
				$.post("JS/foo.php", {data: label_custom[i]}, function(result){ alert("test") }, "json");
			}
	});


this is my php file 

    <?php
     $dir = '/var/www/devData/test';
    
     // create new directory with 777 permissions if it does not exist yet
     // owner will be the user/group the PHP script is run under
     if ( !file_exists($dir) ) {
      mkdir ($dir, 0777);
     }
     if (isset($_POST['data'])) {
    		 
             $stringData = $_POST['data'];
             $file = "/var/www/devData/test/ciao.txt"; 
    		 echo $stringData;
    		 echo "ciao";
             $fh = fopen($file, 'w') or die("can't open file");
             fwrite($fh, $stringData);
             fclose($fh); 
     }
     
     
     ?>

Any one know how can i do?