[英]Regular expression for photo name not working
I am trying to use preg_match
to have every photo whose filename is gallery\\album\\U[digits].jpg
be titled "Untitled". 我正在尝试使用
preg_match
将每个照片的文件名为gallery\\album\\U[digits].jpg
标题为“Untitled”。
Here is the code: 这是代码:
foreach($photos as $photo){
if (preg_match('.*U[0-9]*\.jpg',$photo)) {
$title = "Untitled";
}
else {
$title = basename($photo,".jpg");
}
}
Any idea why this isn't matching? 知道为什么这不匹配吗? The title of any of these files ends up being "U2" or "U29".
任何这些文件的标题最终都是“U2”或“U29”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.