[英]How to find string between two “/” characters - php
What I'm trying to do is edit the value of a folder when the title is changed. 我正在尝试做的是在更改标题时编辑文件夹的值。 The title is directly associated with the folder and as such, for consistency, the folder needs to be updates.
标题直接与文件夹相关联,因此,为了保持一致,需要更新文件夹。
What I have pre-stored so far is: 到目前为止,我已经预存储了:
Pictures/Title/image.png
What i want to do is get out "Title" which will always be between two / characters. 我想要做的是退出“标题”,该标题始终在两个/字符之间。 Then take that out of the string and replace it with the new title.
然后从字符串中删除该字符串,并将其替换为新标题。
preg_match is the obvious function, but i'm unsure of how to use it to find and return the string I want. preg_match是显而易见的功能,但是我不确定如何使用它来查找并返回我想要的字符串。
preg_match("$title" , $ImageLocation, $matches);
$title = $matches
Ideally, that would work if i knew what the title would be but I can't figure out how to both account for the unknown string, and for the special characters. 理想情况下,如果我知道标题是什么,那将是可行的,但我不知道如何同时说明未知字符串和特殊字符。
All i know for certain is that "title", whatever that may be, will be between two "/" characters. 我可以肯定知道的是,“ title”(无论可能是什么)将在两个“ /”字符之间。 The php docs show the use of special characters but i personally cannot fathom how to use the commands as it doesn't appear to be specific.
php文档显示了特殊字符的使用,但是我个人无法理解如何使用命令,因为它似乎并不具体。 Any help's appreciated.
任何帮助表示赞赏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.