viankakrisna
2/21/2017 - 1:31 PM

php2jsx

php2jsx

var string = `copy your php here`


console.log(
  string
    .replace(/class=/g, 'className=')
    .replace(/<\?php/g, '{')
    .replace(/\?>/g, '}')
    .replace(/echo/g, '')
    .replace(/{ endif; }/g, '}')
    .replace(/{ endif;}/g, '}')
    .replace(/{endif; }/g, '}')
    .replace(/{endif;}/g, '}')
    .replace(/{ endif }/g, '}')
    .replace(/{endif }/g, '}')
    .replace(/{ endif}/g, '}')
    .replace(/{endif}/g, '}')
    .replace(/;/g, '')
    .replace(/global $/g, 'global.')
    .replace(/\$/g, 'props.')
    .replace(/<br>/g, '<br />')
    .replace(/<hr>/g, '<hr />')
    .replace(/->/g, '.')
    .replace(/if\((.*?)\):}/g, '$1 && ')
    .replace(/if \((.*?)\):}/g, '$1 && ')
)