how to convert this code substr in php to javascript? this code run in php, but run in java script cannot
PHP
<?php
$header='XII-40';
$next=1022;
$len=6;
$id = $header.substr("000000000$next", -$len);
print $id;
https://www.tehplayground.com/Fa2f6Jk0bP4UaLLz
const str = 'XII-14';
const next=123
const text1='00000000001' next
const len =6
console.log(text1.substr(next, len));
CodePudding user response:
This seems to work:
const str = 'XII-14';
const next = 123;
const text1 = '00000000001' next;
const len = 6;
console.log(str text1.substr(-len));
It returns:
XII-14001123