Skip to content
Advertisement

Create array from DOM node values in PHP

I’m trying to create an array of amazon product variants using DOM php, My desired array should look like;

JavaScript

Here is my code:

JavaScript

Though my code is working but there are some mistakes in code and it might wont work for all amazon products. so I need suggestions and improvement. and also my output is a json object :

JavaScript

while I want it to be an array as I mentioned above.

Advertisement

Answer

JavaScript

Which outputs:

JavaScript

When tested with a new url it yielded:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement