Simple XML to Array Trouble!

Hey guys, Im trying to go through this SimpleXML and make my own array out of it, I simplified it so it’s easy to read here:

The data I get:

SimpleXMLElement Object
(
    [status] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [text] => hey
                    [source] => Jesse Testing

The loop I do for each of them

$result = simplexml_load_string($result);
	
$i = 0;
foreach ($result->status as $key => $value)
{
	$output[$i]['source'] = $value->text;
	$output[$i]['text'] = $value->source;
	$i++;
}

The output

[4] => Array
	(
		[text] => SimpleXMLElement Object
			(
				[0] => hey
			)

		[source] => SimpleXMLElement Object
			(
				[0] => Jesse Testing
			)

	)

Desired Output

[4] => Array
	(
		[text] => hey
		[source] => Jesse Testing

	)

foreach ($result->status as $key => $value)
{
    $output[$i]['source'] = (string)$value->text;
    $output[$i]['text']   = (string)$value->source;
    $i++;
}

Ah, excellent thank you sir :slight_smile: !