String : fmt_map=22%2F2000000%2F9%2F0%2F115%2C34%2F0% Code (markup): What I need to do is to get the first number. In this case, I need to get "22" ( number can be anything - it can be 5, it can be 22, or even 150 ). I've the following preg_match : preg_match('/fmt_map\=(.*)%/', $content, $fmt); PHP: Now, the problem is that it does not return me the right value ! Instead of returning 22, it returns the whole ( most part of it ) string. Any solutions ?
May be this is not the right solution.but what i will do is $fmt_map=22%2F2000000%2F9%2F0%2F115%2C34%2F0% $values=explode("%",$fmt_map); echo $values[0]; Still i am saying this is not the solution what you expected. But try this.
Well, I could do it in 5 other ways as well ! I just want to keep my code as clean as possible and do things in the right way Anyway, thanks for help ! Still looking for someone who have an idea on how to fix this.
For fmt_map at the beginnin ( else '#^\w=(\d+)#' ) $content='fmt_map=22%2F2000000%2F9%2F0%2F115%2C34%2F0%'; $arr=array(); if (preg_match('#^fmt_map=(\d+)#',$content,&$arr)) echo $arr[1]; PHP: Regards
Someone already mentioned it ( and I already knew that I can do in that way as well ), but thanks anyway