Replace string containing double qoutes and colon

I have this string saved in $metaV:

{"feedName":"Paypal Test","paypalEmail":"managercvtech@gmail.com","mode":"test","transactionType":"subscription","recurringAmount":"form_total","billingCycle_length":"1","billingCycle_unit":"day","recurringTimes":"0","recurringRetry":"0","trial_enabled":"1","trial_product":"73","trial_amount":"","trialPeriod_length":"1","trialPeriod_unit":"month","billingInformation_firstName":"4","billingInformation_lastName":"27","billingInformation_email":"5","billingInformation_address":"","billingInformation_address2":"","billingInformation_city":"","billingInformation_state":"","billingInformation_zip":"34","billingInformation_country":"","pageStyle":"","continueText":"","cancelUrl":"","disableShipping":"0","disableNote":"0","delayNotification":"0","selectedNotifications":"","feed_condition_conditional_logic":"0","feed_condition_conditional_logic_object":{"conditionalLogic":{"actionType":"show","logicType":"all","rules":[{"fieldId":"73","operator":"is","value":"1 month"}]}},"type":"subscription","recurring_amount_field":"form_total","update_user_action":"","delay_registration":"","update_site_action":""}

I want to replace this part of the string:

"trial_enabled":"0"

I tried to use str_replace() for this:

str_replace('\"trial_enabled\":\"1\"', '\"trial_enabled\":\"0\"',$metaV);

Answers


You could use json_decode and json_encode to transform your string into an array and the way back.

$data = json_decode($metaV, true);
$data['trial_enabled'] = "1";
$metaV = json_encode($data);

Need Your Help

How to change Setup.exe icon when publishing through clickonce

c# asp.net visual-studio-2012 clickonce setup-deployment

Is there any way to set custom icon for setup.exe file when publishing through VS for click once publish.

Can I import .obj files for use on the iPad

objective-c iphone ipad

Is it possible to create 3D models in other applications (e.g. Vue Esprit) and then export these models as .obj files for use in iPad applications?