add xml child in first index of an array using php : im stuck for hours to solve this problem. i have multiple array contains mathml(xml) element. for example my arraylist

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

    Array
    (
        [0] => <mi>x</mi><mo>=</mo><mfrac><mrow><mo>-</mo><mi>b</mi>      <mo>±</mo><msqrt><msup><mi>b</mi><mn>2</mn></msup><mo>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac>
        [1] => <mi>x</mi><mo>+</mo><mn>2</mn><mo>=</mo><mn>3</mn>
        [2] => <mfrac><mrow><mn>2</mn><mi>x</mi><mo>+</mo><mn>2</mn></mrow><mn>3</mn></mfrac><mo>-</mo><mn>3</mn><mo>=</mo><mn>2</mn>
        [3] => <mo>-</mo><mn>3</mn><mo>+</mo><mn>2</mn><mo>=</mo><mi>x</mi>
    )

<!-- end snippet -->

i want all array start with <mo>, if its start with <mo> and then it fine like array [3].

for example the array i want

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

    Array
    (
        [0] =><mo>+</mo><mi>x</mi><mo>=</mo><mfrac><mrow><mo>-</mo><mi>b</mi><mo>±</mo><msqrt><msup><mi>b</mi><mn>2</mn></msup><mo>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac>
        [1] =><mo>+</mo><mi>x</mi><mo>+</mo><mn>2</mn><mo>=</mo><mn>3</mn>
        [2] =><mo>+</mo><mfrac><mrow><mn>2</mn><mi>x</mi><mo>+</mo><mn>2</mn></mrow><mn>3</mn></mfrac><mo>-</mo><mn>3</mn><mo>=</mo><mn>2</mn>
        [3] =><mo>-</mo><mn>3</mn><mo>+</mo><mn>2</mn><mo>=</mo><mi>x</mi>
    )

<!-- end snippet -->

as you can see all array start with <mo>,

below is my current coding to add it

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

    $ress = array();
    $arr_result=[];
    for ($i=0; $i <= $length ; $i++) { 
        $ress=$result[$i];
        if ($pos = (substr($ress,0,3)!="<mo>")) {
            $arr_result[]=array_unshift($ress, "<mo>+</mo>");
        }
        else{
            $arr_result[]=$ress;    
        }
        
    }
    print_r($arr_result);

<!-- end snippet -->

    $result store the array. 
thanks in advance