how to remove whitespaces from each beginning of a php string

Viewed 21

How to execute align left for text? This is one variable text string which server got, so need transform it, ust like execute align left for all line but save other format if it possible

standart preg_replace("/^\s+/", "", $text) remove all saces but need only from begginig on new line actual text

Resolved
        devic_name: my_device_name - device title if available, if not - fqhost or remote ip address
        device_url : http://test/#/groups/de5a4eb96125d63a6fb330d6afbf44fbe9077a0ba796de1f40e28f70d8489362 - direct url to the device page on the qbee platform
        device_link: [my_device_name](http://test/#/groups/de5a4eb96125d63a6fb330d6afbf44fbe9077a0ba796de1f40e28f70d8489362) - html construct my_device_name
        title: devpi1 - device title which can be set on the device page
        fqhost: devpi1 - the fully qualified name of the host
        remoteaddr: ip: 188.95.241.148 - remove IP addres of the device
        alert_name: parser - name of the alert
        alert_url: http://test/some_path/alert/837f2ad5-7b42-4434-87ea-b4e1793dc212 - direct url to the alert page
        alert_link: [parser](http://test/some_path/alert/837f2ad5-7b42-4434-87ea-b4e1793dc212) - html construct parser

expected

Resolved
devic_name: my_device_name - device title if available, if not - fqhost or remote ip address
device_url : http://test/#/groups/de5a4eb96125d63a6fb330d6afbf44fbe9077a0ba796de1f40e28f70d8489362 - direct url to the device page on the qbee platform
device_link: [my_device_name](http://test/#/groups/de5a4eb96125d63a6fb330d6afbf44fbe9077a0ba796de1f40e28f70d8489362) - html construct my_device_name
title: devpi1 - device title which can be set on the device page
fqhost: devpi1 - the fully qualified name of the host
remoteaddr: ip: 188.95.241.148 - remove IP addres of the device
alert_name: parser - name of the alert
alert_url: http://test/some_path/alert/837f2ad5-7b42-4434-87ea-b4e1793dc212 - direct url to the alert page
alert_link: [parser](http://test/some_path/alert/837f2ad5-7b42-4434-87ea-b4e1793dc212) - html construct parser

I did it like that

        $transText = "";
    foreach(preg_split("/((\r?\n)|(\r\n?))/", $text) as $line){
        $transText .= trim($line) . PHP_EOL;
    }

but maybe there are mor useful cases ?

0 Answers
Related