Post by Joe1234 » Sun May 15, 2022 2:43 pm

I don't know if the title fits, so let me know if I need to correct it. Here is what I'm trying to modify:

Code: Select all

		foreach ($results as $result) {
			$json[] = array(
				'id' => $result['product_id'],
				'status' => $result['status'],
				'image' => $this->model_tool_image->resize(($result['image'] ? $result['image'] : 'no_image.png'), 40, 40),
				'name' => strip_tags(html_entity_decode($result['product_id'], ENT_QUOTES, 'UTF-8')));
		}
I'm trying to do edit the 'name' like:

Code: Select all

'name' => strip_tags(html_entity_decode($result['product_id'], ENT_QUOTES, 'UTF-8')))." - ".strip_tags(html_entity_decode($result['sku'], ENT_QUOTES, 'UTF-8')));
But it doesn't work. How do I combine the two elements to a variable in the array.

Thanks.
Last edited by Joe1234 on Sun May 15, 2022 10:12 pm, edited 1 time in total.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by mikeinterserv » Sun May 15, 2022 10:07 pm

Try

Code: Select all

'name' => $result['product_id'] . ' - ' . $result['sku'];
Last edited by mikeinterserv on Sun May 15, 2022 10:30 pm, edited 3 times in total.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by Joe1234 » Sun May 15, 2022 10:11 pm

I was just coming back to say I figured it out:

Code: Select all

'name' => strip_tags(html_entity_decode($result['name'].' - '.$result['sku'], ENT_QUOTES, 'UTF-8')));
I'll try your way for the hell of it to see if it works. Thanks.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by mikeinterserv » Sun May 15, 2022 10:25 pm

If you want name why did you put product_id + Sku instead of name + sku :-)

Code: Select all

'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')) . ' - ' . $result['sku'];
Strip tags and decode are not required for integer. Only text.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by Joe1234 » Mon May 16, 2022 1:42 pm

The product id was an accident, I put it in while I was hacking around trying to figure out the issue and happened to copy that iteration over.

Thanks for the info about the strip tags. Just so I know, is there any downside in keeping it the way I have it vs yours?

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am
Who is online

Users browsing this forum: No registered users and 267 guests