0

i am using this code and its getting No ending delimiter '/' found

if (preg_match("/", $desp))
{
    $dp = explode("/",$desp);

    $dp1 = $dp[0];
    $dp2 = $dp[1];
}

in $desp i have value like abc/xyz then it should be like

$dp1 = abc
$dp2 = xyz

so what is the right code thnx.

4

2 回答 2

1

您应该改用 strpos 。无论如何,您收到该错误的原因是该模式没有分隔符。

带分隔符的模式示例:

if (preg_match("~/~", $desp))

但是,您应该做什么:

if (strpos($desp, '/') !== false)
于 2012-05-18T07:52:41.307 回答
0

那样做

$str = "abc/xyz";
$pattern = '/\//';
if(preg_match($pattern, $str))
    echo "foo";

你必须用反斜杠转义你的斜杠才能让它工作

于 2012-05-18T07:52:25.007 回答