Tags_list and formatting printed result

Hi.
I’m using this code to pull a list of all tags in an account.

The output I get is formated

Array
(
    [0] => Array
        (
            [id] => 454
            [name] => STATUS: Client
            [count] => 0
        )

    [1] => Array
        (
            [id] => 23
            [name] => STATUS: Lead
            [count] => 0
        )

What I’d like is just a simple list of tags.
STATUS: Client
STATUS: Lead

Is this possible and if so, can you point me to something that would help me get the result I’m after?

Thanks for your time.
Cheers
Shane

Hello @Shane,

To print out just the list of Tag names you will want to iterate through the $result object using a foreach loop and then echo the name property for each one. Here is a simple example:

foreach($result as $tag) { //Iterate through all tags
    echo $tag['name'] . PHP_EOL; //List the tagname and add a newline for output readability.
}

To make this work with the example code that you were using, you will want to replace the following line of code from the example with the new code:
print_r($result);

If you are viewing this output as HTML in the browser, you may want to replace the . PHP_EOL portion with an HTML linebreak instead.

I hope this helps point you in the right direction!

-Matt

Hi @mreibach. Thank you for getting back to me. Just what I needed.
Cheers

2 Likes