php - How to remove whitespace between a <td> tag until the string? -


i have string

<td>    text</td><td>  july 3, 2013</td> 

i want remove leading spaces resulting string looks like

<td>some text</td><td>july 3, 2013</td> 

i playing around preg_replace, can't seem figure out proper syntax.

preg_replace('/<td>\s+/', '<td>', $strip2); **<-doesn't work** 

your regexp works perfectly:

<?php $str = "<td>    text</td><td>  july 3, 2013</td>"; $str = preg_replace('/<td>\s+/', '<td>', $str); print $str; 

prints:

<td>some text</td><td>july 3, 2013</td> 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -