0

I want to pass a PHP array as URL parameter in GET method . Here is my php array : Array ( [0] => 4 [1] => 5 )

1st I convert it to angularJs array like this

$scope.myData.excludeList = '<?php echo JSON_encode($savedList);?>';

Then I pass this array like this :

$scope.myData = {};
$scope.myData.array =[];
var response = $http({
    url: 'http://localhost/control/file_list/', 
    method: "GET",
    params: $scope.myData.array 
});
response.success(function (data){
    $scope.list = data.list;
});

But when it hit the URL look like

http://localhost/control/file_list/%5%%22 lab lab lab.... how can I solve this ?

2 Answers 2

1

Here is a good solution I think

var formData = {                        
                data1: val1,
                data1: val2
               };
Sign up to request clarification or add additional context in comments.

Comments

0
var myJsonString = JSON.stringify(yourArray);

Convert array to JSON

then in php

json_decode($myJsonString, true);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.