2012-07-13 4 views
-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"; 

"/로 끝나고 /로 끝나는 출력을 찾고 /">.변수의 특정 데이터를 가져옵니다

출력 : 전체 일을 가정

+0

그 인용이 필요로 탈출한다. (또는 모든 것을 이중 대신 작은 따옴표로 묶으십시오.) 그대로, 오류가 발생합니다. 나는 당신이'$ vari'의 내용이 무엇인지 보여주는 것을 의미하는 것 같아요. 실제 코드의 줄이 아니겠습니까? – Wiseguy

답변

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]); 
0

을 돕는

affection and personal 
all of human kindness 

감사가 제대로 문자열을 이스케이프, 모든 부분의 배열을 얻기 위해이 기능을 사용할 수 있습니다

<?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); 

?> 

또는 정규식 접근 방식으로 이동하십시오. 유효한 라인이 될 수 있도록

나는이 문제에 대한 최선의 해결책이 아니라고해야하지만, 확실히 빠른 하나

관련 문제