<?php
function converteParaJson( $str ) {
//Primeiro iremos converter fazer um parser para JSON +ou- assim:
//Cria as temporadas
$str = preg_replace ( '#^(|\s)+(\d+)(\s|)\{#' , '"$2": {' , $str ) ; $str = preg_replace ( '#\}(\s|)+(\d+)\{#' , '}, "$2": {' , $str ) ;
//Cria os episódios
$str = preg_replace ( '#(\d+)(\s+|)\-(\s+|)([^\r\n]+)#' , '"$1": "$4",' , $str ) ;
//Remove virgulas extras
$str = '{' . $str . '}' ;
return $str ;
}
$txt = '1{
1 - Episódio número 1 na 1ª Temporada
2 - Episódio número 2 na 1ª Temporada
}
2{
1 - Episódio número 1 na 2ª Temporada
2 - Episódio número 2 na 2ª Temporada
}' ;
$txt = converteParaJson( $txt ) ;
//Converte o json para array do php
PD9waHAKCmZ1bmN0aW9uIGNvbnZlcnRlUGFyYUpzb24oJHN0cikgewogICAgLy9QcmltZWlybyBpcmVtb3MgY29udmVydGVyIGZhemVyIHVtIHBhcnNlciBwYXJhIEpTT04gK291LSBhc3NpbToKCiAgICAvL0NyaWEgYXMgdGVtcG9yYWRhcwogICAgJHN0ciA9IHByZWdfcmVwbGFjZSgnI14ofFxzKSsoXGQrKShcc3wpXHsjJywgJyIkMiI6IHsnLCAkc3RyKTsKICAgICRzdHIgPSBwcmVnX3JlcGxhY2UoJyNcfShcc3wpKyhcZCspXHsjJywgJ30sICIkMiI6IHsnLCAkc3RyKTsKCiAgICAvL0NyaWEgb3MgZXBpc8OzZGlvcwogICAgJHN0ciA9IHByZWdfcmVwbGFjZSgnIyhcZCspKFxzK3wpXC0oXHMrfCkoW15cclxuXSspIycsICciJDEiOiAiJDQiLCcsICRzdHIpOwogICAgCiAgICAvL1JlbW92ZSB2aXJndWxhcyBleHRyYXMKICAgICRzdHIgPSBwcmVnX3JlcGxhY2UoJyMsW1xzXStcfSMnLCAnfScsICRzdHIpOwogICAgCiAgICAkc3RyID0gJ3snIC4gJHN0ciAuICd9JzsKICAgIAogICAgcmV0dXJuICRzdHI7Cn0KCi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