Current location: Hot Scripts Forums » Programming Languages » PHP » Extract 1st word of string/insert in middle of new string


Extract 1st word of string/insert in middle of new string

Reply
  #1 (permalink)  
Old 10-26-11, 05:26 PM
valuser valuser is offline
New Member
 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Extract 1st word of string/insert in middle of new string

Wordpress Website Name (say) = "German Philosophy Politics & Economics"

I want to return "My German Site"

I have tried the following :

Code:
<?php
$myvalue = bloginfo('name');
$arr = explode(' ',trim($myvalue));
$var = $arr[0];
echo "My ".$var." Site";
?>
but it returns "German My Site"

not "My German Site"

Any ideas ?
Reply With Quote
  #2 (permalink)  
Old 10-28-11, 05:25 AM
phplabs phplabs is offline
Newbie Coder
 
Join Date: Oct 2011
Posts: 37
Thanks: 0
Thanked 7 Times in 7 Posts
what you say seems to be not true.

<?
$myvalue = "German Philosophy Politics & Economics";
$arr = explode(' ', trim($myvalue));
$var = $arr[0];
echo "My ".$var." Site";

that's your code, i just assigned $myvalue a specific value (because i don't know what the value of bloginfo() is) and the script says 'My German Site', just as you need.
__________________
blog.phplabs.net
Reply With Quote
Reply

Bookmarks

Tags
first word, string


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OOP C-Sharp DB Access Wrapper Question digioz ASP.NET 1 09-08-08 09:54 AM
search function using dot net nishudude_13 Windows .NET Programming 1 08-28-08 11:28 AM
Shell scripting : how to extract a particular word from a string onlynimal Script Requests 0 07-26-07 12:58 AM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM


All times are GMT -5. The time now is 08:52 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.