I need to replace 3 Hebrew Unicode characters into another 3 Hebrew Unicode characters. I looked into PHP syntax and searched but this is the best I could write. It works and does the job.
I'm wondering and would like to know if this is the most optimal way of replacing a Unicode character into another Unicode character in PHP before I turn this into a tiny little function.
Is there a better syntax in PHP for this?
$re1 = '/[\x{05B1}]/u';
$re2 = '/[\x{05B2}]/u';
$re3 = '/[\x{05B3}]/u';
$subst1 = json_decode('"\u05B6"');
$subst2 = json_decode('"\u05B0"');
$subst3 = json_decode('"\u05B8"');
//Replace (Niqqud with Cantillation) with (just Niqqud)
$bible_content = preg_replace($re1, $subst1, $bible_content);
$bible_content = preg_replace($re2, $subst2, $bible_content);
$bible_content = preg_replace($re3, $subst3, $bible_content);
Starting input for $bible_content:
וַ/יִּקְרָא אֱלֹהִים לָ/אוֹר יוֹם וְ/לַ/חֹשֶׁךְ קָרָא לָיְלָה וַ/יְהִי עֶרֶב וַ/יְהִי בֹקֶר יוֹם אֶחָד׃ אַשְׁרֵי הָ/אִישׁ אֲשֶׁר לֹא הָלַךְ בַּ/עֲצַת רְשָׁעִים וּ/בְ/דֶרֶךְ חַטָּאִים לֹא עָמָד וּ/בְ/מוֹשַׁב לֵצִים לֹא יָשָׁב׃ חֳ
Expected output for $bible_content:
וַ/יִּקְרָא אֶלֹהִים לָ/אוֹר יוֹם וְ/לַ/חֹשֶׁךְ קָרָא לָיְלָה וַ/יְהִי עֶרֶב וַ/יְהִי בֹקֶר יוֹם אֶחָד׃ אַשְׁרֵי הָ/אִישׁ אְשֶׁר לֹא הָלַךְ בַּ/עְצַת רְשָׁעִים וּ/בְ/דֶרֶךְ חַטָּאִים לֹא עָמָד וּ/בְ/מוֹשַׁב לֵצִים לֹא יָשָׁב׃ חָ