I've got a long string which I want to split accross multiple lines so it's easier to read. but I'm not sure what the syntax is
$xml = array('sXML' =>"<queryxml><entity>Ticket</entity><query><field>Status<expression op=\"$condition1\">$complete</expression></field><condition operator=\"AND\"><field>AccountID<expression op=\"equals\">$userid</expression></field></condition><condition operator=\"AND\"><condition><field>QueueID<expression op=\"NotEqual\">$routine</expression></field></condition><condition operator=\"OR\"><field>QueueID<expression op=\"NotEqual\">$recurring</expression></field></condition><condition operator=\"OR\"><field>QueueID<expression op=\"NotEqual\">$clientmanagement</expression></field></condition></condition></query></queryxml>");
Can someone help me out please?
explode() is a built in function in PHP used to split a string in different strings. The explode() function splits a string based on a string delimiter, i.e. it splits the string wherever the delimiter character occurs. This functions returns an array containing the strings formed by splitting the original string.
Use explode() or preg_split() function to split the string in php with given delimiter. PHP | explode() Function: The explode() function is an inbuilt function in PHP which is used to split a string in different strings.
The splitlines() method splits a string into a list. The splitting is done at line breaks.
Definition and Usage. The str_split() function splits a string into an array.
just split it into multiple strings and concatenate them, like this:
$xml = array('sXML' => "lorem" .
"ipsum" .
"dolor");
or use heredoc:
$sXML = <<<XML
your text
goes here
XML;
$xml = array('sXML' => $sXML);
If it doesn't matter if linebreaks are added, you can simply write:
<?php
$xml = array('sXML' => "<abc>
<def>Asdfg</def>
</abc>";
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With