fork(1) download
  1. <?php
  2.  
  3. $texto = "[pt-br]
  4.  
  5. Qual é Lorem Ipsum?
  6.  
  7. Lorem Ipsum é simplesmente texto manequim da impressão e composição indústria. Lorem Ipsum tem sido o texto padrão do manequim da indústria desde os anos 1500, quando uma impressora desconhecida tomou uma galera de tipo e mexidos-lo para fazer um livro tipo espécime. Ele sobreviveu não apenas cinco séculos, mas também o salto para composição eletrônica, permanecendo essencialmente inalterado. Foi popularizado na década de 1960 com o lançamento de folhas Letraset contendo Lorem Ipsum passagens, e mais recentemente com software de editoração como Aldus PageMaker, incluindo versões de Lorem Ipsum.
  8.  
  9. [/pt-br][en-us]
  10.  
  11. What is Lorem Ipsum?
  12.  
  13. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  14.  
  15. [/en-us][en]
  16.  
  17. What is Lorem Ipsum?
  18.  
  19. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  20.  
  21. [/en]";
  22.  
  23.  
  24. $output = array();
  25. preg_match_all("/\[(.*?)\]/", $texto, $output);
  26. $result = array();
  27. for($i = 0; $i < count($output[0]); $i = $i + 2)
  28. {
  29. $ini = strripos($texto, $output[0][$i]);
  30. $end = strripos($texto, $output[0][$i+1]);
  31. $result[str_replace(['[',']'],'',$output[0][$i])] =
  32. str_replace($output[0],'', substr($texto, $ini, $end - $ini));
  33.  
  34. }
  35.  
  36. var_dump($result);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
array(3) {
  ["pt-br"]=>
  string(646) "

Qual é Lorem Ipsum?

Lorem Ipsum é simplesmente texto manequim da impressão e composição indústria. Lorem Ipsum tem sido o texto padrão do manequim da indústria desde os anos 1500, quando uma impressora desconhecida tomou uma galera de tipo e mexidos-lo para fazer um livro tipo espécime. Ele sobreviveu não apenas cinco séculos, mas também o salto para composição eletrônica, permanecendo essencialmente inalterado. Foi popularizado na década de 1960 com o lançamento de folhas Letraset contendo Lorem Ipsum passagens, e mais recentemente com software de editoração como Aldus PageMaker, incluindo versões de Lorem Ipsum.

"
  ["en-us"]=>
  string(600) "

What is Lorem Ipsum?

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

"
  ["en"]=>
  string(600) "

What is Lorem Ipsum?

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

"
}