regex - PHP: Return string between two characters -


i wanting use "keywords" within large string. these keywords start , end using my_keyword , user defined. how, within large string, can search , find between 2 * characters , return each instance?

the reason might change it, parts of keywords can user defined, such page_date_y might show year in page created.

so, again, need search , return between * characters. possible, or there better way of doing if don't know "keyword" length or might be?

<?php // keywords between * $str = "php *best*, *most popular* , *i* love it.";     if(preg_match_all('/\*(.*?)\*/',$str,$match)) {                     var_dump($match[1]);             } ?> 

output:

array(3) {   [0]=>   string(4) "best"   [1]=>   string(12) "most popular"   [2]=>   string(1) "i" } 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -