FT3 Posted March 1, 2012 Report Share Posted March 1, 2012 sveiki izvadu no datubazes ( wowowow.lv ) ka uzlikt pie izvades ja nav http:// tad to pieliek bet ja ir neko nedara. paldies. Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted March 1, 2012 Report Share Posted March 1, 2012 (edited) Vai: foreach($links as &$link) if(substr($link, 0, 7) !== 'http://' and substr($link, 0, 8) !== 'https://') $link = "http://{$link}"; Edited March 1, 2012 by rATRIJS Quote Link to comment Share on other sites More sharing options...
FT3 Posted March 1, 2012 Author Report Share Posted March 1, 2012 (edited) Warning: Invalid argument supplied for foreach() in C:\AppServ\www\index.php on line 4 <?php $links = 'wowowow.lv'; foreach($links as &$link){ if(substr($link, 0, 7) !== 'http://' and substr($link, 0, 8) !== 'https://') $link = "http://{$link}"; } echo $link; ?> Edited March 1, 2012 by FT3 Quote Link to comment Share on other sites More sharing options...
FT3 Posted March 1, 2012 Author Report Share Posted March 1, 2012 <?php $links = 'wowowow.lv'; if(substr($links, 0, 7) !== 'http://'){ $link = 'http://'.$links.''; }else{ $link = $links; } echo $link; ?> Quote Link to comment Share on other sites More sharing options...
101111 Posted March 2, 2012 Report Share Posted March 2, 2012 Code Igniter freimworkā pieejamais risinājums /** * Prep URL * * Simply adds the http:// part if no scheme is included * * @access public * @param string the URL * @return string */ if ( ! function_exists('prep_url')) { function prep_url($str = '') { if ($str == 'http://' OR $str == '') { return ''; } $url = parse_url($str); if ( ! $url OR ! isset($url['scheme'])) { $str = 'http://'.$str; } return $str; } } 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.