-1
我需要在php中替换两个字符之间的一部分字符串,最后一个连字符和最后一个点。有任何想法吗?替换连字符和点之间的字符串的一部分在php
$string = 'http://example.com/wp-content/uploads/2015/07/2b146fdab6c33eb5ca12efe61424427b-1000x750.jpg'
数字可以变化,1000x750只是一个例子。
$newstring = 'http://example.com/wp-content/uploads/2015/07/2b146fdab6c33eb5ca12efe61424427b-600x400.jpg'
谢谢!
你有没有尝试过的东西或者做了一些研究? – Rizier123
我确实设法在字符串上添加新字符串,而不用像连字符 '$ first_img =''; ob_start(); ob_end_clean(); $ output = preg_match_all('//i',$ post-> post_content,$ matches); $ first_img = $ matches [1] [0]; $ first_img = substr($ first_img,0,-4)。' - 600x450'。 substr($ first_img,-4);' –
然后在你的问题中显示你的努力以及你被困在哪里。 – Rizier123