diff --git a/examples/post_multiple_values_same_key_with_indexes_explicit.php b/examples/post_multiple_values_same_key_with_indexes_explicit.php new file mode 100644 index 0000000..f5a6c0d --- /dev/null +++ b/examples/post_multiple_values_same_key_with_indexes_explicit.php @@ -0,0 +1,12 @@ +post('https://httpbin.org/post', array( + 'foo[0]' => 'bar', + 'foo[1]' => 'baz', +)); diff --git a/examples/post_multiple_values_same_key_with_indexes_implicit.php b/examples/post_multiple_values_same_key_with_indexes_implicit.php new file mode 100644 index 0000000..44c4570 --- /dev/null +++ b/examples/post_multiple_values_same_key_with_indexes_implicit.php @@ -0,0 +1,14 @@ +post('https://httpbin.org/post', array( + 'foo' => array( + 'bar', + 'baz', + ), +)); diff --git a/examples/post_multiple_values_same_key_without_indexes.php b/examples/post_multiple_values_same_key_without_indexes.php new file mode 100644 index 0000000..c3435b1 --- /dev/null +++ b/examples/post_multiple_values_same_key_without_indexes.php @@ -0,0 +1,31 @@ + $value) { + $key = rawurlencode($key); + if (is_array($value)) { + foreach ($value as $v) { + $v = rawurlencode($v); + $array[] = $key . '=' . $v; + } + } else { + $value = rawurlencode($value); + $array[] = $key . '=' . $value; + } + } + return implode('&', $array); +} + +$curl = new Curl(); +$curl->post('https://httpbin.org/post', http_build_query_without_indexes(array( + 'foo' => array( + 'bar', + 'baz', + ), +)));