0

I have the following snippet of function and call to another function for returning tabs to format code.

public function makelinks ($urls_data) {
    ...code...
    $i = 5;
    $tabs   = $this->echo_tabs($i);
    $output = "$tabs<ul class=\"url_list\">\n";
    ...code...
}

public function echo_tabs($i){
    $x  = 0;
    $o = '';
    for ($x;$x<$i;$x++) {
        $o .= "\t"; 
    }
    return $o;
}

What I would like is for $output to result in \t\t\t\t\t<ul class=\"url_list\">\n the \t's translating to actual tabs when a browser view source is generated. I am aware if I simply had that block string of characters assigned to $output, then they would have the desired result in the browser. Instead the \t's are echoing out as a string and displaying as unformatted and unwanted text.

To try and generate the desired result, I have also tried $o .= '\t'; as well as $o .= "\\t";. Neither of these is working either. I have googled a lot on this using terms such as 'assigning tabs to variable php'.

What would be the method for prepending or appending strings of tabs to code so they translate as tabs?

Edited by dwlamb: clarity

2
Contributors
2
Replies
20
Views
3 Years
Discussion Span
Last Post by dwlamb
0

It works perfectly well in my browser (Firefox 30 on Win7). Clicking on a View page source it shows 5 tabs.

0

Don't I feel like an idiot. I have no idea what I was doing wrong last night. It was late when I tried working on this. It was not working so I thought Leave it. Document what you did and post it somewhere in the morning.

Tried it again and it works no problem

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.