Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As i see, you have a set of tables within one string. And you need to split string to tables. I assume you could split the string with the text, separating tables.</p> <pre><code>&lt;?php $s = &lt;&lt;&lt;EOSTR First table | | {{Категория}} | | {{Стоимость курсов}} | {{Стоимость учебного набора}} | | 1 | Взрослый | 1 уровень = 50ч | 1~500 лей | 15 евро | | 2 | Студент, Мастерант, Докторант | 1 уровень = 50ч | 1~000 лей | 15 евро | | 3 | Ученик | 1 уровень = 50ч | 1~000 лей | 15 евро | | 4 | Пенсионер | 1 уровень = 50ч | 1~000 лей | 15 евро | text text text text text text Second table: | | {{Вид курсов}} | | {{Стоимость курсов}}| {{Стоимость учебного набора}} | | 1 | dfgdfgdfg | 1 модуль | 500 лей | 0 | |^|^| 2 модуля | 900 лей | 0 | |^|^| 4 модуля | 1~500 лей | 0 | | 2 | fgdfgdfg | 12ч | 800 лей | 0 | | 3 | dfgdfgdfgdfg| 12ч | 900 лей | 0 | |^|^| Предварительный тест | 400 лей | 0 | text text text text text text EOSTR; $a = null; $a = preg_split('/^(?:.(?&lt;!\|))*$/xm', $s); var_dump($a); </code></pre> <p>Just like here: <a href="http://ideone.com/VCt4f" rel="nofollow noreferrer">http://ideone.com/VCt4f</a> (using <a href="https://stackoverflow.com/questions/876927/regex-for-matching-lines-that-do-not-contain-a-word">this question</a>). This will give you this:</p> <pre><code>array(5) { [0]=&gt; string(0) "" [1]=&gt; string(506) " | | {{Категория}} | | {{Стоимость курсов}} | {{Стоимость учебного набора}} | | 1 | Взрослый | 1 уровень = 50ч | 1~500 лей | 15 евро | | 2 | Студент, Мастерант, Докторант | 1 уровень = 50ч | 1~000 лей | 15 евро | | 3 | Ученик | 1 уровень = 50ч | 1~000 лей | 15 евро | | 4 | Пенсионер | 1 уровень = 50ч | 1~000 лей | 15 евро | " [2]=&gt; string(1) " " [3]=&gt; string(466) " | | {{Вид курсов}} | | {{Стоимость курсов}}| {{Стоимость учебного набора}} | | 1 | dfgdfgdfg | 1 модуль | 500 лей | 0 | |^|^| 2 модуля | 900 лей | 0 | |^|^| 4 модуля | 1~500 лей | 0 | | 2 | fgdfgdfg | 12ч | 800 лей | 0 | | 3 | dfgdfgdfgdfg| 12ч | 900 лей | 0 | |^|^| Предварительный тест | 400 лей | 0 | " [4]=&gt; string(0) "" } </code></pre> <p>When you're done extracting tables you could simply split them to columns with</p> <pre><code>// $a = preg_split... foreach ($a as $table) { if (!strlen(trim($table))) continue; $rows = preg_split('/\n/', $table); foreach ($rows as $row) { if (!strlen(trim($row))) continue; $columns = preg_split('/\|/', $row); // work with $columns array } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload