How can I get the name of the current directory - not the whole path?

Possible Duplicate:
How to get the last dir from a path in a string

I'm using getcwd() to return something like this: home/abc123/public_html/blah/myDir

How can I modify this string to simply return myDir?

-------------Problems Reply------------

http://php.net/manual/en/function.basename.php

Either use basename:

print basename("home/abc123/public_html/blah/myDir");
//Output: myDir

Or strpos and substr:

$fullPath = "home/abc123/public_html/blah/myDir";
print substr($fullPath, strrpos($fullPath, "/") + 1);
//Output: myDir

Category:php Views:1 Time:2011-07-10
Tags: php

Related post

  • Evidence for sealed class performance benefit 2008-08-05

    I have come across a lot of optimization tips which say that you should mark your classes as sealed to get extra performance benefits. I ran some tests to check the performance differential and found none. Am I doing something wrong? Am I missing the

  • Using a DOS command in Ruby script 2008-08-05

    How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby? --------------Solutions------------- This explanation is based on this commented Ruby script from a friend of mine. If you want t

  • DISCUSSION - Uploading and Storing Mass Images 2008-08-06

    So I'm using an app that stores images heavily in the DB. What's your outlook on this? I'm more of a type to store the location in the filesystem, than store it directly in the DB. What do you think are the pros/cons? --------------Solutions---------

  • storing files to a database or just to the local hard-disk? 2008-08-06

    So I'm using an app that stores images heavily in the DB. What's your outlook on this? I'm more of a type to store the location in the filesystem, than store it directly in the DB. What do you think are the pros/cons? --------------Solutions---------

  • Where is a good place to start programming GUIs for windows? 2008-08-07

    I have experience writing console and network client/server applications in C and C++, but I know next to nothing about using the win32 visual API, MFC, Qt, wxWidgets, etc. Where is a good place to start, and what method should I specialize in, so as

  • How to include PHP files that require an absolute path? 2008-08-07

    I have a directory structure like the following; /script.php /inc/include1.php /inc/include2.php /objects/object1.php /objects/object2.php /soap/soap.php Now, I use those objects in both script.php and /soap/soap.php, I could move them, but I want th

  • How do I retrieve my MySQL username and password? 2008-08-07

    I lost my MySQL username and password. How do I retrieve it? --------------Solutions------------- Stop the MySQL process. Start the MySQL process with the --skip-grant-tables option. Start the MySQL console client with the -u root option. List all th

  • Where can I get the Windows Workflow "wca.exe" application? 2008-08-07

    I am walking through the MS Press Windows Workflow Step-by-Step book and in chapter 8 it mentions a tool with the filename "wca.exe". This is supposed to be able to generate workflow communication helper classes based on an interface you provide it.

  • How do I update Ruby Gems from behind a Proxy (ISA-NTLM) 2008-08-07

    Firewall I'm behind is running Microsoft ISA server (NTLM only mode), anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method? ... or am I just being lazy? Edit: rubysspi-1.2.4 does not work UPDATE: This also w

  • ruby script/plugin discover RuntimeError 2008-08-07

    Firewall I'm behind is running Microsoft ISA server (NTLM only mode), anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method? ... or am I just being lazy? Edit: rubysspi-1.2.4 does not work UPDATE: This also w

  • Vista or XP for Dev Machine 2008-08-07

    I am about to get a new PC from work, and it will include the option to have either Vista Business as the OS, or a downgrade to XP Pro. Aside from a tiny bit of testing, I have never used Vista, but overall I have heard many more bad reports than goo

  • MAPI and managed code experiences? 2008-08-07

    Using MAPI functions from within managed code is officially unsupported. Apparently, MAPI uses its own memory management and it crashes and burns within managed code (see here and here) All I want to do is launch the default e-mail client with subjec

  • Using Xming X Window Server over a VPN 2008-08-07

    I have the Xming X Window Server installed on a laptop running Windows XP to connect to some UNIX development servers. It works fine when I connect directly to the company network in the office. However, it does not work when I connect to the network

  • DVCS Choices - What's good for Windows? 2008-08-07

    So I want to get a project on a distributed version control system, such as mercurial, git, or bazaar. The catch is that I need the Windows support to be good, i.e. no instructions that start off with "install cygwin...". Now I've heard that git's Wi

  • Using ConfigurationManager to load config from an arbitrary location 2008-08-07

    I'm developing a data access component that will be used in a website that contains a mix of classic ASP and ASP.NET pages, and need a good way to manage its configuration settings. I'd like to use a custom ConfigurationSection, and for the ASP.NET p

  • Flex / Air obfuscation 2008-08-07

    I've written (most of) an application in Flex and I am concerned with protecting the source code. I fired up a demo of Trillix swf decompiler and opened up the swf file that was installed to my Program Files directory. I saw that all of the actionscr

  • How should I organize my master ddl script 2008-08-07

    I am currently creating a master ddl for our database. Historically we have used backup/restore to version our database, and not maintained any ddl scripts. The schema is quite large. My current thinking: Break script into parts (possibly in separate

  • Open local file with AIR / Flex 2008-08-07

    I have written an AIR Application that downloads videos and documents from a server. The videos play inside of the application, but I would like the user to be able to open the documents in their native applications. I am looking for a way to prompt

  • How to add CVS directories recursively 2008-08-07

    I've played with CVS a little bit and am not the most familiar with all of its capabilities, but a huge annoyance for me is trying to add new directories that contain more directories in them. Running "cvs add" only adds the contents of the current d

  • Learning Ruby on Rails any good for Grails? 2008-08-07

    My company is in the process of starting down the Grails path. The reason for that is that the current developers are heavy on Java but felt the need for a MVC-style language for some future web development projects. Personally, I'm coming from the d

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.095 (s). 11 q(s)