Question: i want to add `utm_source=twitter` in the of the links

i have a link let say
<http://abcd.com/news?id=1>

it need to be `http://abcd.com/news?id=1&utm_source=twitter`

if <http://abcd.com/news/1>

it need to be 

```
http://abcd.com/news/1?utm_source=twitter

```

any idea?

Answer: 
You can check if the URL already contains a query string and branch your logic accordingly:

```
if (strpos($url, '?') === FALSE) {
    $url .= '?utm_source=twitter';
} else {
    $url .= '&utm_source=twitter';
}

```
If you're simply adding it to the end of a link it would look something like

```
$link . "?utm_source=twitter";

```