Guys when I try to fetch user avatar i get:
$test['avatar'] == uploads/avatars/avatar_825.gif?dateline=1409257842
How to strip everything from this string except avatar_825.gif
try this : (haven't really had time to test it on other scenarios of use)
<?php
$avatar = "uploads/avatars/avatar_825.gif?dateline=1409257842";
$matches = array();
if(preg_match("/^uploads\/avatars\/(([a-zA-Z0-9_-])+\.(jpeg|jpg|gif|png|bmp))\?dateline\=([0-9])+$/i", $avatar, $matches)) {
$avatar_path = $matches[1];
}
$avatar is the equivalent of your $test['avatar'].
You are amazing!
Maybe it's better to use
str_replace cause the avatar is not a static value but changes every time?
$yutuytuy = str_replace(array("./", ".."), "", $posts['avatar']);
$yutuytuy2 = str_replace("uploads/avatars/",'',$yutuytuy);
EDIT!!!!!!
Here is my ugly code I would really appreciate if someone could clean it up.
$yutuytuy = str_replace(array("./", ".."), "", $posts['avatar']);
$yutuytuy2 = str_replace("uploads/avatars/",'',$yutuytuy);
$copy_date = preg_replace("/dateline=[0-9]+/", "", $yutuytuy2);
$new_title = str_replace('?', '', $copy_date);