I have created a method called breadcrumbs() that returns an array.
I have noticed when I output the array as per the first example below, I am getting unwanted white space in the browsers I have tested (Firefox, Chrome, Safari).
First Example:
<div>
<? foreach($kb->breadcrumbs() as $key => $value){ ?>
<a href="<? =$key ?>"><? =$value ?></a>
<? } ?>
</div>
But if I handle the array like this second example, no unnecessary whitespace appears.
Second example:
<div>
<? foreach($kb->breadcrumbs() as $key => $value){
echo '<a href="'.$key.'">'.$value.'</a>';
} ?>
</div>
What am I doing wrong in the first example? I thought the first way was the preferred method as it is better at separating the PHP logic from the HTML presentation?