Any change for more direct array response?
-
My response looks like this
`
+”yoast_meta”: array:11 [▼
0 => {#600 ▼
+”name”: “description”
+”content”: “Shop page meta description”
}
1 => {#598 ▼
+”name”: “robots”
+”content”: “noindex,follow”
}
2 => {#612 ▼
+”property”: “og:locale”
+”content”: “en_US”
}
3 => {#605 ▼
+”property”: “og:type”
+”content”: “article”
}
4 => {#596 ▼
+”property”: “og:title”
+”content”: “Shop – Storename”
}
5 => {#614 ▼
+”property”: “og:description”
+”content”: “Shop page meta description”
}
6 => {#615 ▼
+”property”: “og:url”
+”content”: “https://myurl.com/shop”
}
7 => {#616 ▼
+”property”: “og:site_name”
+”content”: “Sitename”
}
8 => {#617 ▼
+”name”: “twitter:card”
+”content”: “summary_large_image”
}
9 => {#618 ▼
+”name”: “twitter:description”
+”content”: “Shop page meta description”
}
10 => {#619 ▼
+”name”: “twitter:title”
+”content”: “Shop – Storename”
}
]
`
as you can see the object/array names are inconstant. That means in a foreach loop you have to check if the yoast_meta has “name” or “property” on each.
To speed things up is there a way to make the array more associative like
`
+”yoast_meta”: array:11 [▼
“description” : “Shop page meta description”,
“robots” : “noindex,follow”,
“og:locale”: “en_US”,
“og:type”: “article”,
“og:title”: “Shop – Storename”,
“og:description”: “Shop page meta description”,
“og:url”: “https://myurl.com/shop”
“og:site_name”: “Sitename”
“twitter:card”: “summary_large_image”
“twitter:description”: “Shop page meta description”
“twitter:title”: “Shop – Storename”
]
`
Thanks in advance.
- The topic ‘Any change for more direct array response?’ is closed to new replies.