Regular expression
Posted
by
atno
on Stack Overflow
See other posts from Stack Overflow
or by atno
Published on 2011-01-04T03:30:05Z
Indexed on
2011/01/04
3:53 UTC
Read the original article
Hit count: 283
php
|preg-match
Hi
I have an array that its first element might contains something like [some text, here. That's some text]
I'm trying to figure out a pattern to check if such string exists and if not create it but having problem with making the pattern. Here's what I've done so far
$pattern = '/^\[*\]$/';
if(preg_match($pattern,$exploded[0])){
$name = array_shift($exploded);
}else{
$name = "[Unnamed import] - " .gmdate("His");
}
But I always get [Unnamed import] - 032758 even when I'm sure that pattern match
© Stack Overflow or respective owner