extract or get first string from current url in php


More accurate representation of relationship b...

extract or get first string from current url in php

$url =”$_SERVER[‘REQUEST_URI’]”;

or

$url=”https://ephptutorial.wordpress.com/category/internal-messaging-system-in-codeigniter/”;

$path =

$url);
$newpath = $path[‘path’];
$new = explode(‘/’,$newpath);
echo $new[2];//

Result:

category

Advertisements
About

myself pramodh kumar yet another php developer from India and have worked on oops,procedural,yii framework,codeigniter,wordpress,joomla,api and more.

Tagged with: , , , , , , ,
Posted in extract or get first string from current url in php

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow php tutorial on WordPress.com
categories
Calendar
October 2013
M T W T F S S
« Sep   Nov »
 123456
78910111213
14151617181920
21222324252627
28293031  
Follow me on Twitter
Blog Stats
  • 72,886 hits
%d bloggers like this: