Skip to content

Instantly share code, notes, and snippets.

@wilcorrea
Created April 7, 2017 05:03
Show Gist options
  • Save wilcorrea/e1284a1f3d7368eb49d91a328b0d72d4 to your computer and use it in GitHub Desktop.
Save wilcorrea/e1284a1f3d7368eb49d91a328b0d72d4 to your computer and use it in GitHub Desktop.
<?php
$text = '
APRESENTAÇÕES
Loren Ipsum
1. INDICAÇÕES
Loren Ipsum
2. RESULTADOS DE EFICÁCIA
Loren Ipsum
3. CARACTERÍSTICAS FARMACOLÓGICAS
Loren Ipsum
4. CONTRAINDICAÇÕES
Loren Ipsum
5. ADVERTÊNCIA E PRECAUÇÕES
Loren Ipsum
6. INTERAÇÕES MEDICAMENTOSAS
Loren Ipsum
7. CUIDADOS DE ARMAZENAMENTO DO MEDICAMENTO
Loren Ipsum
8. POSOLOGIA E MODO DE USAR
Loren Ipsum
9. REAÇÕES ADVERSAS
Loren Ipsum
10. SUPERDOSE
Loren Ipsum';
$topics = [
'1. INDICAÇÕES',
'2. RESULTADOS DE EFICÁCIA',
'3. CARACTERÍSTICAS FARMACOLÓGICAS',
'4. CONTRAINDICAÇÕES',
'5. ADVERTÊNCIA E PRECAUÇÕES',
'6. INTERAÇÕES MEDICAMENTOSAS',
'7. CUIDADOS DE ARMAZENAMENTO DO MEDICAMENTO',
'8. POSOLOGIA E MODO DE USAR',
'9. REAÇÕES ADVERSAS',
'10. SUPERDOSE'
];
$contens = [];
$last = '_';
foreach ($topics as $key => $topic) {
$node = explode($topic, $text);
$contents[] = [
'section' => $last,
'content' => $node[0]
];
$text = $node[1];
$last = $topic;
}
var_dump($contents);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment