mirror of
https://github.com/moodle/moodle.git
synced 2025-03-18 22:50:19 +01:00
MDL-20616 support for array of arrays in postdata
This commit is contained in:
parent
d3e3bd6cbc
commit
06f0784845
@ -865,10 +865,23 @@ function download_file_content($url, $headers=null, $postdata=null, $fullrespons
|
||||
|
||||
// use POST if requested
|
||||
if (is_array($postdata)) {
|
||||
$data = array();
|
||||
foreach ($postdata as $k=>$v) {
|
||||
$postdata[$k] = urlencode($k).'='.urlencode($v);
|
||||
if (is_array($v)) {
|
||||
foreach ($v as $sk=>$sv) {
|
||||
if (is_array($sv)) {
|
||||
foreach ($sv as $ssk=>$ssv) {
|
||||
$data[] = urlencode($k).'['.urlencode($sk).']['.urlencode($ssk).']='.urlencode($ssv);
|
||||
}
|
||||
} else {
|
||||
$data[] = urlencode($k).'['.urlencode($sk).']='.urlencode($sv);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data[] = urlencode($k).'='.urlencode($v);
|
||||
}
|
||||
}
|
||||
$postdata = implode('&', $postdata);
|
||||
$postdata = implode('&', $data);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user