src/Strings.php
public function injectParams($string, $params = array())
    {
        $links = preg_split('#(<a\b[^>]+>)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
        $old   = $links;

        foreach ($links as &$match) {
            if (preg_match('/<a\b/', $match) && !preg_match('/(?:#|mailto)/', $match)) {
                preg_match('/^([^"]+")([^"]+)/', $match, $matches);
                if ($matches) {
                    $link = html_entity_decode($matches[2]);
                    if (strpos($link, "?") === false) {
                        $link .= "?";
                    } else {
                        $link .= "&";
                    }

                    $link .= http_build_query($params);

                    $match = str_replace($matches[2], $link, $match);
                }
            }
        }

        $string = str_replace($old, $links, $string);
        return $string;
    }
public function injectParams($string, $params = array())
    {
        $links = preg_split('#(<a\b[^>]+>)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
        $old   = $links;

        foreach ($links as &$match) {
            if (preg_match('/<a\b/', $match) && !preg_match('/(?:#|mailto)/', $match)) {
                preg_match('/^([^"]+")([^"]+)/', $match, $matches);
                if ($matches) {
                    $link = html_entity_decode($matches[2]);
                    if (strpos($link, "?") === false) {
                        $link .= "?";
                    } else {
                        $link .= "&";
                    }

                    $link .= http_build_query($params);

                    $match = str_replace($matches[2], $link, $match);
                }
            }
        }

        $string = str_replace($old, $links, $string);
        return $string;
    }
public function injectParams ( $ string , $ params = array ( ) ) { $ links = preg_split ( '#(<a\b[^>]+>)#' , $ string , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ old = $ links ; foreach ( $ links as & $ match ) { if ( preg_match ( '/<a\b/' , $ match ) && ! preg_match ( '/(?:#|mailto)/' , $ match ) ) { preg_match ( '/^([^"]+")([^"]+)/' , $ match , $ matches ) ; if ( $ matches ) { $ link = html_entity_decode ( $ matches [ 2 ] ) ; if ( strpos ( $ link , "?" ) === false ) { $ link .= "?" ; } else { $ link .= "&" ; } $ link .= http_build_query ( $ params ) ; $ match = str_replace ( $ matches [ 2 ] , $ link , $ match ) ; } } } $ string = str_replace ( $ old , $ links , $ string ) ; return $ string ; }
Injects GET params in links

@param string $string
@param array $params
@return string
Injects GET params in links