php - Replace text from the middle of the string -


<table border="1">   <tr>     <th>id</th>      <th>filepath</th>    </tr>   <tr>     <th>1</th>      <th>uploads/1233/a.jpg</th>    </tr>   <tr>     <th>2</th>      <th>uploads/1213/b.jpg</th>    </tr>   <tr>     <th>3</th>      <th>uploads/1243/c.jpg</th>    </tr>   <tr>     <th>4</th>      <th>uploads/1234/d.jpg</th>    </tr>   <tr>     <th>5</th>      <th>uploads/1273/e.jpg</th>   </tr> </table> 

id , filepath coming mysql table. want replace numeric value between uploads folder , image name.

how do in mysql or in php?

try preg_replace function php.

$filepath = "uploads/1233/a.jpg"; echo preg_replace('/(?<=\/)[1-9][0-9]*?(?=\/)/', "replacement_string_for_the_numeric_value", $filepath); 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -