PHP and JavaScript function

When you are in a position of Full Stack developer and you need implement back-end in PHP and use JavaScript for front-end, it is good to have some functions which are used for similar operations in both languages.

Rounded value in JavaScript:

 var i  =  1.233342;
 document.write(i.toFixed(2));

Rounded value in PHP

$i = 1.233342;
print round($i, 2);

Splitting and joining strings in JavaScript

test = str.split('_'); 
str = test.join('_');

Splitting and joining strings in PHP

$test = explode('_',$str);
$str = implode('_', $test);