how can i make this code display $anchor with spaces. I would have Text Anchor1 and Text Anchor two insitead of TextAnchor1 and TextAnchor2. Thank you
$currentsite = get_bloginfo('wpurl');
           $sites = array(
           'TextAnchor1' => 'http://www.开发者_JS百科mysite1.com',
           'TextAnchor2' => 'http://www.mysite2.com'
           );
           foreach($sites as $anchor => $site) 
           {
           if ( $site !== $currentsite ){echo '<li><a href="'.$site.'" title="'.$anchor.'" target="_blank">'.$anchor.'</a></li>';}
           } 
So, as you $anchor values probably aren't hard-coded, I assume what you really need is a function that takes a string as an argument and inserts spaces before any capital letters or numbers.
function splitWords($s){
return trim(preg_replace('/([A-Z0-9])/', ' \1', $s));
}
Later, when writing output, instead of $anchor, you can use splitWords($anchor).
$sites = array(
           'Text Anchor 1' => 'http://www.mysite1.com',
           'Text Anchor 2' => 'http://www.mysite2.com'
           );
Ooh, ooh, my turn.
$sites = array(
           'Text Anchor 1' => 'http://www.mysite1.com',
           'Text Anchor 2' => 'http://www.mysite2.com'
           );
Just change to:
$sites = array(
    'Text Anchor' => 'http://www.mysite1.com',
    'My Text Anchor' => 'http://www.mysite2.com'
);
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论