alconebay Posted April 3, 2008 Share Posted April 3, 2008 Say I have a car website and the structure of the page titles will always be something like: "The Carguide's Camero Information." All my page titles will follow this format so I want to be able to assign the third word of the page title (in this example, "Camero") to a variable that I can use throughout the page. Is this where that "explode" function comes in? Thanks Link to comment https://forums.phpfreaks.com/topic/99375-solved-assign-third-word-in-page-titles-to-a-variable/ Share on other sites More sharing options...
Xil3 Posted April 3, 2008 Share Posted April 3, 2008 Say I have a car website and the structure of the page titles will always be something like: "The Carguide's Camero Information." All my page titles will follow this format so I want to be able to assign the third word of the page title (in this example, "Camero") to a variable that I can use throughout the page. Is this where that "explode" function comes in? Thanks I guess you could use explode... not sure how your code is layed out though... $t = "The Carguide's Camero Information."; $t_arr = explode(" ", $t); echo $t_arr[2]; // Camero Link to comment https://forums.phpfreaks.com/topic/99375-solved-assign-third-word-in-page-titles-to-a-variable/#findComment-508460 Share on other sites More sharing options...
alconebay Posted April 3, 2008 Author Share Posted April 3, 2008 Thanks! That works beautifully. Here is how I'm using it in my site: <head> <?php $title="The Carfan Camero Page"; $title_arr = explode(" ", $title);?> <title><? echo $title; ?></title> </head> <html> Welcome to the <? echo $title_arr[2]; ?> page of Carfan. </html> Link to comment https://forums.phpfreaks.com/topic/99375-solved-assign-third-word-in-page-titles-to-a-variable/#findComment-508482 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.