PHP получение нового массива с подменой содержимого
Доброй ночи, в post запросе получаю данные вида:
{"{\"typeOrder\":\"followers или likes или views\",\"type\":\"good или standart или premium\",\"count\":500,\"price\":60,\"discount\":30,\"d\":42_86,\"link\":\"rewrwe\"}":""}
typeOrder имеет следующие типы: followers, likes, views
type имеет следующие типы: standart, good, premium
на выходе нужно получить новый массив но с заменой некоторого содержимого (сопоставление):
typeOrder:
вместо followers - заменяется на подписчики
вместо likes - заменяется на лайки
вместо views - заменяется на просмотры
type:
вместо standart - заменяется на Обычные
вместо good - заменяется на Хорошие
вместо premium - заменяется на Премиум
Кто может реализовать подмену
$arr["typeOrder"] = "подписчики или лайки или просмотры"; - в зависимости от того что пришло (описано выше)
$arr["type"] = "Обычные или Хорошие или Премиум"; - в зависимости от того что пришло (описано выше)
$arr["count"] = "500";
$arr["price"] = "60";
$arr["link"] = "example.com";
discount - ненужен
-
POST-параметр - это всегда строка в utf-8.
Поэтому, до ее "распарсинга" (обработки) можно сделать желаемую замену обычным str_replace():$phrase = '{"{\"typeOrder\":\"followers или likes или views\",\"type\":\"good или standart или premium\",\"count\":500,\"price\":60,\"discount\":30,\"d\":42_86,\"link\":\"rewrwe\"}":""}'; $then = array('followers', 'likes', 'views', 'standart', 'good', 'premium'); $now = array('подписчики', 'лайки', 'просмотры', 'Обычные', 'Хорошие', 'Премиум'); $newphrase = str_replace($then, $now, $phrase);
И все. -
Current freelance projects in the category PHP
Laravel/Blade developer (middle) — website enhancement
100 USD
I am looking for a developer for a project consisting of 4 related tasks for the website best-matchmaking.com to be completed sequentially:Integration of a ready-made premium Blade template for blog articles + auto-generation of Schema/SEO markup (Article, FAQPage, Open Graph,… PHP ∙ 7 hours 54 minutes back ∙ 36 proposals |
Improvement of the website https://koleso-center.com/ on OpenCart
223 USD
Add categories to the online store websiteUsed disksSpare tiresFastenersData is taken from the 1C database.A few more questions Type of performer: single Backend developer (OpenCart/PHP) at the Middle levelThe modifications must meet all requirementsSEO + AI promotion AI… PHP ∙ 1 day 1 hour back ∙ 43 proposals |
Module for OpenCart: mass creation of products from folders with imagesDevelopment of a mass product creation module for OpenCart (ocStore 3.x) A backend module for OpenCart / ocStore 3.x needs to be developed that automatically creates products from a pre-prepared folder structure with images.Main functionality: mass creation of products from… Content Management Systems, PHP ∙ 2 days 7 hours back ∙ 48 proposals |
Website optimizationOptimization of the website jdgreta.co.uk on Shopify. SEO audit attached to the project. Main tasks - - Fix all meta data - Complete the technical specifications for the programmer (since this project combines tasks for both the programmer and SEO, if you are not a company -… HTML & CSS, PHP ∙ 6 days 6 hours back ∙ 34 proposals |
Horoshop SpecialistNeed a specialist who can correctly set up the product Feed. Problem: Currently, over 13,000 products are being uploaded with the same type value (e.g., "everything for manicure and pedicure"). Because of this, it is impossible to segment products in Google Ads and set different… PHP, Website Maintenance ∙ 7 days 8 hours back ∙ 22 proposals |