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.

 

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.

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.