Answers for "javascript parse php code"

PHP
6

javascript access php variable

//passing PHP variable to JavaScript
var myJSVar = <?php echo json_encode($myPHPVar); ?>;
Posted by: Guest on August-05-2019
0

javascript parse php code

let cars = [
    {
        "id": 1,
        "code": "C1",
        "color": "purple",
        "type": "minivan",
        "registration": new Date('2017-01-03'),
        "capacity": 7
    },
    {
        "id": 2,
        "code": "C2",
        "color": "red",
        "type": "station wagon",
        "registration": new Date('2018-03-03'),
        "capacity": 5
    },
    {
        "id": 3,
        "code": "C2",
        "color": "black",
        "type": "station",
        "registration": new Date('2018-03-03'),
        "capacity": 9
    }
]
const s = new Set()
cars.forEach((element) => {
    console.log(element.id)
    console.log(s.has(element.code) ? 0 : element.code)
    s.add(element.code)
    console.log(element.color)
    console.log(element.type)
    console.log(element.capacity)
});
Posted by: Guest on November-10-2021

Browse Popular Code Answers by Language