$url = "https://www.sparktraffic.com/api.php"; $fields = array( 'key'=>urlencode('7111ee02ef5c48623ea0807d9aeaaba'), 'action'=>urlencode('balance'), ); $fields_string = ""; foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }