Jump to content

Need help making this backward compatible until php upgrade


xxclear

Recommended Posts

Can some help me make this code backward compatible?

 

 

This code works with php 5.3 and above. I need it to work with 5.2.17.

$columns = 'col1, col2, col3';
$values = '$value1, $value2, $value3';

$result = implode(
', ',
array_map(
function ($c, $v) {
return $c . ' = ' . $v;
},
explode(',', $columns),
explode(',', $values)
)
);

var_dump($result); //this returns: col1 = $value1, col2 = $value2, col3 = $value3

Cheers.

 

Link to comment
Share on other sites

Thanks for your reply, that alone returns:

var_dump($result); //this returns: col1, $value1, col2, $value2, col3, $value3

Notice "=" isn't inserted between each exploded result. What do i need to do to get that function to work between each result?

FYI i get: PHP Parse error: syntax error, unexpected T_FUNCTION, expecting ')'

In the original code.

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.