can anybody suggest me how to convert angular js dynamic array into php array and then submit value of php array in any new file. in my program i am working in arraytest.php and want to send php array in saveform.php in php format. please anybody help me to do this. thanks
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="myform" action="saveform.php" method="post">
<div ng-app="myApp" ng-controller="MyCtrl" data-ng-init="input.var1=input.var2=''">
<div ng-repeat="input in inputs" >
<input type="text" value="254" ng-model= "input.var1"/>
<input type="text" ng-model="input.var2"/>
<button type='button' ng-click='remove(input)'>Remove</button>
</div>
<div>
<button type='button' ng-click='add()'>Add</button>
</div>
<p style="display:none">TotalDays = {{getTotal(value)}}</p><br><br>
<div ng-repeat="dateTimeList in myarray">
<!-- first value: <input type ="text" value="{{ fir_value = dateTimeList.first }}">
second value: <input type ="text" value="{{ sec_value = dateTimeList.second }}">-->
<p>{{ fir_value = dateTimeList.first }}</p>
<p>{{ sec_value = dateTimeList.second }}</p>
<?php
$array1 = array("{{fir_value}}","{{sec_value}}");
print_r($array1);
?>
</div>
<input type="submit" name="submit" />
</div>
<script>
angular.module('myApp', [])
.controller('MyCtrl', function($scope) {
$scope.inputs = [{}]; // default 1 sets
$scope.add = function()
{
$scope.inputs.push({});
}
$scope.getTotal = function(a)
{
var total = 0,first_value=0,second_value=0, total2 = 0;
$scope.myarray = [{}];
angular.forEach($scope.inputs, function(value)
{ // loop over array to process all items
first_value = value.var1;
second_value = value.var2;
$scope.myarray.push({first:first_value,second:second_value});
});
return total;
}
// coding for remove button
$scope.remove = function(item) {
angular.forEach($scope.inputs, function(value, key) {
if (value == item) {
$scope.inputs.splice(key, 1);
}
});
}
});
</script>
</script>
</body>
</html>
here is another file saveform.php
<?php
echo "output of array is:- ";
extract($_POST);
if(isset($submit))
{
print_r($arr);
}
?>
plnkr demo: http://plnkr.co/edit/20PLT52Ia86UyGClQh7h?p=preview