I want to get some random code from URL beginning with some word (d_
and r_
)
Example:
1. domain.com/index/book-one-d_123456
2. domain.com/index/book-one-r_123456
I want to show if the link is "d_123456" show content for "d_123456" and if "r_123456" show content for "r_123456". And explode random code after "d_" or "r_".
I have tried with:
if ($co){
$rand = explode('/',$co);
if (preg_match('/^.*([d_]).*?$/i', $rand[1]))
{
$res = explode("d_",$rand[1]);
some code..........
{
else if (preg_match('/^.*([r_]).*?$/i', $soid[1]))
{
$res = explode("r_",$rand[1]);
some code..........
}
I can get random code from "d_" but I can't get it working for "r_" or seems not detecting.
for I'm sorry I posted to early and Thanks for your help guys :D already found a solution from this post : https://stackoverflow.com/a/4366744/5118751
I just change :
if ($co){
$rand = explode('/',$co);
if (preg_match('/d_/', $rand[1]))
{
$res = explode("d_",$rand[1]);
some code..........
{
else if (preg_match('/r_/', $soid[1]))
{
$res = explode("r_",$rand[1]);
some code..........
}
and now everthing working perfect ...