Jump to content

explode string to array, different delimiters


akaweed

Recommended Posts

hey guys, I apologize, as this stuff should be easy to figure out, but I am getting stumped again being a php rookie.  I have searched a lot for an answer before I bothered you all.  Here's the skinny:  I have a string coming in via post content that looks like:

name1\x1ddata1\x1ename2\x1ddata2\x1e ...

where the delimiters are 0x1e for the field/data pairs and 0x1d between the field/data .  there may be as many as 20 of these pairs in the string.  I have the string and I can store the pairs with explode in an array correctly, I just cant seem to get them all into one array.  it would be even more helpful if the first element of the pairs were the array keys.  Any guidance would be helpful.  Thanks

$raw_post_data=file_get_contents("php://input");
$records=explode("\x1e",$raw_post_data,-1);
    foreach($records as $data){
        $pairs=explode("\x1d",$data);}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.