Reputation:
Does anyone have a smart idea how to transform this javascript object into an associative php array?
Note that I don't want to read this into PHP, I want the same data structure in PHP without going through each line and editing it e.g. adding ''
and =>
.
module.exports = {
base: '/',
api: {
sentry: 'https://[email protected]/257382',
wp: {
imgSize: {
_380x270: 'medium',
}
}
},
y: 2017,
href: {
authors: '#',
fb: '#',
instagram: '#',
de: 'https://wearede.com/',
},
faction: {
subscribe: "/",
search: "/",
},
search: {
tags: [{
t: 'Lifestyle',
h: '#'
},
{
t: 'Politics',
h: '#'
},
{
t: 'Economy',
h: '#'
},
],
articles: [{
t: 'იოლანდა ჰადიდმა ჯიჯი ჰადიდის და ზეინ მალიკის ერთობლივი ფოტო გამოაქვეყნა',
h: '#',
},
{
t: 'ლარი ევროსთან მიმართებით რეკორდულად გაუფასურდა',
h: '#',
},
]
},
menuMain: [{
h: '#',
t: 'სიახლეები'
},
{
h: '#',
t: 'ბიზნესი და ტექნოლოგია'
},
{
h: '#',
t: 'Lifestyle'
},
{
h: '#',
t: 'მოგზაურობა'
},
{
h: '#',
t: 'გასტრონომია'
},
{
h: '#',
t: '<i class="i i--hammock fz-20"></i>'
},
],
footer: {
authors: [{
i: 'https://picsum.photos/55/55',
h: '#',
n: 'Rusudan Tinatin',
t: 'Author',
d: 'ლარი ევროსთან მიმართებით რეკორდულად გაუფასურდა',
},
{
i: 'https://picsum.photos/55/55',
h: '#',
n: 'Rusudan Tinatin',
t: 'Author',
d: 'იოლანდა ჰადიდმა ჯიჯი ჰადიდის და ზეინ მალიკის ერთობლივი ფოტო გამოაქვეყნა',
},
{
i: 'https://picsum.photos/55/55',
h: '#',
n: 'Rusudan Tinatin',
t: 'Author',
d: 'ლარი ევროსთან მიმართებით რეკორდულად გაუფასურდა',
},
],
nav: [{
t: 'პირობები',
h: '#'
},
{
t: 'პირადი ინფორმაცია',
h: '#'
},
{
t: 'ჩვენს შესახებ',
h: '#'
},
{
t: 'კონტაქტი',
h: '#'
},
{
t: 'ავტორები',
h: '#'
},
],
cats: [{
t: 'სიახლეები',
h: '#'
},
{
t: 'Lifestyle',
h: '#'
},
{
t: 'გასტრონომია',
h: '#'
},
{
t: 'ბიზნესი და ტექნოლოგია',
h: '#'
},
{
t: 'მოგზაურობა',
h: '#'
},
{
t: 'Hammock',
h: '#'
},
],
articles: {
items: articles.slice(0, 3),
i: 'https://picsum.photos/380/260',
t: 'დეკანოზი გიორგი მამალაძე სასამართლომ დამნაშავედ ცნო',
h: '#',
},
}
}
At the moment I'm considering an option to record macros in vim, but that will take quite some time, and I see potential pitfalls in that approach.
Upvotes: 0
Views: 86
Reputation: 19895
Convert this object into a JSON string. Then in PHP, you can json_decode
and var_export
.
Upvotes: 3