Linking each text word or words divided by comma into an existing URL?

Posted by Mezelderz on Stack Overflow See other posts from Stack Overflow or by Mezelderz
Published on 2013-11-05T03:30:06Z Indexed on 2013/11/05 3:53 UTC
Read the original article Hit count: 116

Filed under:
|
|
|
|

I am trying to auto add each word or words divided by comma into an existing url.

I have url lets say http://stackoverflow.com/search?q=HERE IS THAT TEXT.

I have this function:

function movie_cast( $atts, $content = null ) {
    return '<div class="movie_cast">Cast: '.$content.'</div>';
}

add_shortcode( 'movie_cast', 'movie_cast' );

I am using it: [movie_cast]Actor 1, Actor 2[/movie_cast]

Output from this is just text: Actor 1, Actor 2

How can I get otput it like this: <a href="http://stackoverflow.com/search?q=Actor 1">Actor 1</a>, <a href="http://stackoverflow.com/search?q=Actor 2">Actor 2</a>

© Stack Overflow or respective owner

Related posts about php

Related posts about Wordpress