0
我有這個字符串保存在$metaV
:替換字符串包含雙qoutes和結腸
{"feedName":"Paypal Test","paypalEmail":"[email protected]","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":""}
我想替換字符串的這一部分:
"trial_enabled":"0"
我試圖用str_replace()
此:
str_replace('\"trial_enabled\":\"1\"', '\"trial_enabled\":\"0\"',$metaV);
你在這裏是一個JSON字符串。請參閱:http://stackoverflow.com/q/29308898/3933332如何訪問這些數據並將其存入數組。這樣可以更容易地修改信息。現在你正試圖以錯誤的方式解決問題。 – Rizier123
@ Rizier123噢,是的,我以錯誤的方式去做。感謝您的建議。 –