cosmicsea Posted November 29, 2010 Share Posted November 29, 2010 Im using this code right here for to explode titles in my search engine into individual click-able tags <?php $tobeOmitted=array('stuff'); $tagss = explode(" ", str_replace('-', ' ', $title1)); foreach( $tagss as $key => $value){ if(!in_array($value,$tobeOmitted)) echo "<a href='/search.php?query=$value&search=1' target='rel' title='View search results in new window'> $value</a>"; } } ?> Is there a way I can limit the number of tags for each title to 3? I dont want over 100 links on my page because it looks bad in google so I am trying to cut down some pages that have up to 200 links because of long titles and this would cut things down drastically. Any help is appreciated and thank you. Quote Link to comment Share on other sites More sharing options...
intellix Posted November 29, 2010 Share Posted November 29, 2010 I guess you could do $tagss = explode(" ", str_replace('-', ' ', $title1)); $tagss = array($taggs[0],$taggs[1],$taggs[2]); I think that's what you want? Quote Link to comment Share on other sites More sharing options...
cosmicsea Posted November 29, 2010 Author Share Posted November 29, 2010 I guess you could do $tagss = explode(" ", str_replace('-', ' ', $title1)); $tagss = array($taggs[0],$taggs[1],$taggs[2]); I think that's what you want? That seems to work great, just had to change your typos on taggs. Thanks alot. Quote Link to comment Share on other sites More sharing options...
intellix Posted November 29, 2010 Share Posted November 29, 2010 Copy and pasted yours np! Quote Link to comment Share on other sites More sharing options...
intellix Posted November 29, 2010 Share Posted November 29, 2010 Also just from reading another thread I realise that there's also a function for it: http://www.php.net/array_slice $array = array(1,2,3,4,5,6); $array = array_slice($array,0,3); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.