2012-05-15 2 views
0

작은 클래식 전문 음악 목록 웹 사이트를 운영하고 외부 PHP 파일에 저장되어있는 heredoc에서 장소 이름, 주소, 전화 번호 등 (html 마크 업과 함께)을 가지고 있습니다. . 망고 현악 4 중주가HTML 페이지에서 PHP 변수 검색하기

<?php echo $local_arts_centre; ?> 

에서 공연되며, 장소 정보가 깔끔하게 배치 인쇄 된 있습니다

: 내가 할 모든 쓰기입니다.

나는 텍스트를 검색하지만 "mango string quartet"이라는 문구는 찾을 수 있지만 "local arts center"는 검색 할 수없는 검색 기능을 작성했습니다.

웹 및 PHP 책을 검색했지만 해결책을 찾을 수 없습니다. 어떤 아이디어라도 정말 기뻐할 것입니다. 변수가 isset($var) == null보다 설정되지 않은 경우

+0

질문이 모호한 경우 더 유용한 사용 사례 시나리오를 제공하십시오. – ianace

답변

0

나는

HTML 코드 모르겠어 ...

<!-- list of music --> 
<a href="somefile.php?music=happybirthday">Happy Birthday</a> 
<a href="somefile.php?music=rockandroll">Rock and Roll</a> 
<a href="somefile.php?music=raps">Raps</a> 

그리고 somefile.php

에서
<?php 
     // array for locations if just a few 
     $locations = array("here and there", "ther eand here"); 
     // checking if the name 'music' has a value 
     if (isset($_GET['music'])) { 
      $music = $_GET['music']; 
      // since we have the value of music, lets put some locations to them. 
      switch ($music) { 
       case 'happybirthday': 
        echo "The location is at " . $locations[0]; //hereandthere 
        break; 
       case 'rockandroll': 
        echo "The location is at " . $locations[0]; //hereandthere 
        break; 
       case 'raps': 
        echo "The location is at " . $locations[1]; //thereandhere 
        break; 
       default: 
        echo "Please select a music"; // or something 
      } 
     } else { 
      echo "Please select a music"; // or something 
     } 
    ?> 
0

답장을 보내 주셔서 감사합니다. 내가하려는 것은 콘서트 목록의 웹 페이지를 검색하는 것입니다 (예를 들어, 매우 단순화 된 것).

<div> 

Thursday, 17 May 2012 

The Mango String Quartet will be playing Beethoven, Tavener and Terry Riley at: 

<?php echo $local_arts_centre; ?> 

Concert starts at 7.30pm 

Tickets £10.00 

</div> 

나는 HTML의 모든 것을 통해 검색을 수행

은 (장소의 주소 등 전화 번호를 포함)를 히어 닥 $의 local_arts_centre의 내용을 제외 발견된다. 거기에 heredoc을 파싱하는 방법이 있습니까? 물론 웹 페이지에는 나타나지만 코드를 검색 할 때는 그렇지 않습니다.

누군가가 특정 장소 나 특정 도시에서 콘서트를 검색 할 수 있다면 유용 할 것입니다.

물론 해결 방법이 있지만 그다지 깔끔하지는 않습니다. 나는 다음과 같이 쓸 수 있습니다.

<?php echo $local_arts_centre; /* Local Arts Centre London */ ?> 

이것은 "지역 예술 센터"와 "런던"을 의미합니다.

어쨌든 당신의 제안에 감사드립니다, 나는 이미 포럼에서 많은 아이디어를 발견했습니다.