Searching for a word in a range in the phrase

0

I need to search for a word in a range in the phrase. Example the following sentence:

  

The HTML was created in 1991, by Tim Berners-Lee, at CERN (European   Council for Nuclear Research) in Switzerland. Initially the HTML was   designed to interconnect nearby research institutions, and   share documents with ease. In 1992, the   library ACPU development of WWW, a network of   reach the world, which together with HTML provided the   World Wide Web.

Always in this text I'll separate the word that is between library and development into a variable, which in this case is unique and specific ACPU . I will always have the same text, but the word in the range will always be different.

    
asked by anonymous 11.04.2016 / 15:23

1 answer

1

Try to use preg_match . See the example below:

<?php 
    $str = 'O HTML foi criado em 1991, por Tim Berners-Lee, no CERN (European Council for Nuclear Research) na suíça. Inicialmente o HTML foi projetado para interligar instituições de pesquisa próximas, e compartilhar documentos com facilidade. Em 1992, foi liberada a biblioteca ACPU desenvolvimento WWW ( World Wide Web), uma rede de alcance mundial, que junto com o HTML proporcionou o uso em escala mundial da WEB.';
    $term1 = 'biblioteca';
    $term2 = 'desenvolvimento';

    preg_match('/'.preg_quote($term1).'(.*?)'.preg_quote($term2).'/is', $str, $match);
    echo $match[1];
?>
    
11.04.2016 / 16:21