How to take off 1
in "{1}"
and use it?
+5
A:
if (preg_match('/\{(\d+)\}/', $str, $mtch))
echo $mtch[1];
where $str is '{1}'
by the way, you might wanna anchor that regex like this: /^\{(\d+)\}$/It will make sure the string contains exactly that and it won't match for, let's say 'abcd{4}'
2009-12-11 15:24:29
A:
You can use a preg_replace function to perform a regular expression.
What exactly do you need to do the string.
If you want to get a certain character of the string, $str = '{1}'; $str[1]
will return the 2nd character of the string.
CodeJoust
2009-12-11 15:16:56
A:
Depends on what you actually have .. in the example above this would be enough:
$number = $string{1};
But i guess you need more something like
preg_match('/{([0-9]+)}/', $string, $matches);
$number = $matches[1];
johannes
2009-12-11 15:16:56