Dear people,

There is any function instead of explode which does not add an index in the beginning of every line?

Instead of show:
[0] => Number=0
[1] => Number1=1
[2] => Number2=2

Shows like that:
Number=0
Number1=1
Number2=2

or some function that removes the [0], [1],[2]...

Thanks in advance!
Daniel

Can you post an example of the data you are parsing?

$post_url = "https://process.netpay-intl.com/member/remote_charge.asp";
$post_string = "";

foreach($post_values as $key => $value)
  {
     $post_string .= "$key=" . urlencode($value) . "&"; 
  }
$post_string = rtrim($post_string, "& ");

$request = curl_init($post_url);
     curl_setopt($request, CURLOPT_HEADER, 0);
     curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($request, CURLOPT_POSTFIELDS, $post_string);
     curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
     $post_response = curl_exec($request);

$response_array = explode("&", $post_response);

Make sure you use [code] tags. It makes code easier to read.

As for your problem.

$response = array();
foreach( explode( '&',$post_response ) as $data ) {
    list( $key,$val ) = explode( '=',$data );
    $response[$key] = $val;
}
echo '<pre>' . print_r( $response,true ) . '</pre>';

Just ran that. I think its what you are looking for.

Also, look into these functions. parse_str() and http_build_query() - PHP 5 only. I personally haven't used them, but they should help simplify some of your code.

Thanks a lot, that works great!
Dniel

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.