-1
$vari="Love is an emotion of a strong <"/affection and personal/"> attachment. Love is also a virtue representing <"/all of human kindness/">, compassion, and affection";

</"/ で始まり /"> で終わる出力を探します。

出力:

affection and personal
all of human kindness

助けてくれてありがとう

4

2 に答える 2

1
$vari='Love is an emotion of a strong <"/affection and personal/"> attachment. '
   . 'Love is also a virtue representing <"/all of human kindness/">, '
   . ' compassion, and affection';
preg_match_all('@<"/(.*?)/">@', $vari, $matches);
var_dump($matches[1]);
于 2012-07-13T03:52:41.733 に答える
0

全体が適切にエスケープされた文字列であると仮定すると、この関数を使用してすべての部分の配列を取得できます

<?php

function cutMultiple($start, $end, $from)
{
    $results = array(); // init the output
    $step1 = explode($start, $from);    // get the results

    for( $i = 1; $i<count($step1); $i++)
    {
        $outputs = explode($end, $step1[$i]);   // get final cut
        $results[] = $outputs[0];   // append the cut
    }

    return $results;
}

$text = 'Love is an emotion of a strong <"/affection and personal/"> attachment. Love is also a virtue representing <"/all of human kindness/">, compassion, and affection';

echo cutMultiple('<"/', '/">', $text);

?>

または、正規表現のアプローチを使用してください。

これは問題の最善の解決策ではないと言わざるを得ませんが、間違いなく迅速な解決策です

于 2012-07-13T03:56:03.603 に答える