UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

54 lines (44 loc) 1.58 kB
--- layout: page title: "JavaScript octdec function" comments: true sharing: true footer: true alias: - /functions/view/octdec:482 - /functions/view/octdec - /functions/view/482 - /functions/octdec:482 - /functions/482 --- <!-- Generated by Rakefile:build --> A JavaScript equivalent of PHP's octdec {% codeblock math/octdec.js lang:js https://raw.github.com/kvz/phpjs/master/functions/math/octdec.js raw on github %} function octdec (oct_string) { // From: http://phpjs.org/functions // + original by: Philippe Baumann // * example 1: octdec('77'); // * returns 1: 63 oct_string = (oct_string + '').replace(/[^0-7]/gi, ''); return parseInt(oct_string, 8); } {% endcodeblock %} - [Raw function on GitHub](https://github.com/kvz/phpjs/blob/master/functions/math/octdec.js) Please note that php.js uses JavaScript objects as substitutes for PHP arrays, they are the closest match to this hashtable-like data structure. Please also note that php.js offers community built functions and goes by the [McDonald's Theory](https://medium.com/what-i-learned-building/9216e1c9da7d). We'll put online functions that are far from perfect, in the hopes to spark better contributions. Do you have one? Then please just: - [Edit on GitHub](https://github.com/kvz/phpjs/edit/master/functions/math/octdec.js) ### Example 1 This code {% codeblock lang:js example %} octdec('77'); {% endcodeblock %} Should return {% codeblock lang:js returns %} 63 {% endcodeblock %} ### Other PHP functions in the math extension {% render_partial _includes/custom/math.html %}