I'm trying to get the data from a website using php curl. From the output, I need to neglect all the white spaces and empty lines. I used some regex. I'm really not familiar with Regex.
Please help me solve this problem.
There is my code:
if(preg_match('/<div class="search-results-details-body">(.*?) <div class="search-results-details-footer">/s', $result, $output))
{
$stripped_result = ltrim(strip_tags($output[1]));
$refined_output = str_replace(' ','',$stripped_result);
$regex = preg_replace('[\n\n]', "\n", $refined_output); exit();
}
and this is my output in order:
Requirements
Minimum 2 years of web development experience is required
Experience with PHP, MySQL, HTML, CSS, and JavaScript are preferred
Bachelors Degree in Computer Science or related field
Full knowledge and experience of software development lifecycle
Strong organisational and analytical skills
Ability to work under pressure to meet deadlines and required quality standards
Ability to multi-task and prioritize responsibilities
Excellent oral and written communication skills
here i want to remove all the starting white spaces. i need to get the output like this :
Requirements
Minimum 2 years of web development experience is required
Experience with PHP, MySQL, HTML, CSS, and JavaScript are preferred
Bachelors Degree in Computer Science or related field
Full knowledge and experience of software development lifecycle
Strong organisational and analytical skills
Ability to work under pressure to meet deadlines and required quality standards
Ability to multi-task and prioritize responsibilities
Excellent oral and written communication skills
Please suggest a good solution
Thank you