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);}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.