我在新的WordPress插件的工作,但我需要一個定期expresison幫助,所以請如果你能幫助,我有這個定期爲一個字符串序列化數據
a:6:{s:5:"width";s:4:"3000";s:6:"height";s:4:"2100";s:14:"hwstring_small";s:23:"height=\'89\' width=\'128\'";s:4:"file";s:25:"2012/02/sopa_nicearma.jpg";s:5:"sizes";a:3:{s:9:"thumbnail";a:3:{s:4:"file";s:23:"sopa_nicearma-15x10.jpg";s:5:"width";s:2:"15";s:6:"height";s:2:"10";}s:6:"medium";a:3:{s:4:"file";s:25:"sopa_nicearma-300x210.jpg";s:5:"width";s:3:"300";s:6:"height";s:3:"210";}s:5:"large";a:3:{s:4:"file";s:25:"sopa_nicearma-700x490.jpg";s:5:"width";s:3:"700";s:6:"height";s:3:"490";}
}s:10:"image_meta";a:10:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";}}
,但我想刪除這個表達式
s:9:"thumbnail";a:3:{s:4:"file";s:23:"sopa_nicearma-15x10.jpg";s:5:"width";s:2:"15";s:6:"height";s:2:"10";}
,並最終有這個
'a:6:{s:5:"width";s:4:"3000";s:6:"height";s:4:"2100";s:14:"hwstring_small";s:23:"height=\'89\' width=\'128\'";s:4:"file";s:25:"2012/02/sopa_nicearma.jpg";s:5:"sizes";a:3:{s:6:"medium";a:3:{s:4:"file";s:25:"sopa_nicearma-300x210.jpg";s:5:"width";s:3:"300";s:6:"height";s:3:"210";}s:5:"large";a:3:{s:4:"file";s:25:"sopa_nicearma-700x490.jpg";s:5:"width";s:3:"700";s:6:"height";s:3:"490";}
}s:10:"image_meta";a:10:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";}}
所以,在我要刪除的結束,這種中刪除
鏈{鏈 「的名字像」 鏈}
我有這樣的想法
$var=preg_replace("(.+)\{(.+)(sopa_nicearma\-15x10\.jpg)(.+)\}/", "", $var);
但不做工精細becouse我有這個
}s:10:"image_meta";a:10:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";}}
您應先反序列化該值,然後再進行修改,然後再次序列化。 – hakre 2012-02-24 22:38:28
有沒有理由不想先將其反序列化? – StackOverflowNewbie 2012-02-25 01:31:38
是的,因爲我從wordpress的數據庫中直接取得值,以及我不知道這是一個序列化的值,但謝謝你的問題 – nicearma 2012-03-20 14:35:08