I am stuck for several hours with the following problem. I got my own cms where i use a shortcode [plugin-pluginname]
to activate a plugin. Now i want to assign a group within that shortcode which is later used in the include once file as variable for a query to select that certain id.
On the moment, I got the following code:
$regex = '~\[plugin-([^]]+)]~';
$content_one = htmlspecialchars_decode($page['content_one']);
$parts = preg_split($regex, $content_one, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach($parts as $k => $v){
if($k & 1)
include_once('plugins/'.$v.'/'.$v.'.php');
else
echo htmlspecialchars_decode($v);
}
This checks where there is [plugin-testplugin]
(testplugin as an example) and includes that certain file. Now i want to write something like this [plugin-testplugin 2]
where not only the above code still works of course, but also that the number is stored in a variable where is can use the query SELECT * FROM 'database' WHERE 'group' = "'.$var_from_shortcode.'"
Any help and answers to approach and solve this problem are welcome!
Could you use this regex then save group 1 value in a variable?
\[plugin-[A-Za-z ]*(\d+)?\]
Or use this regex to find [plugin-testplugin 2]
then use \d*
to find the number in it?