Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

string manupulation

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

string manupulation

Postby smartbishal » Thu May 22, 2014 9:26 pm

suppose there are list of files, whose name structure is like:: bik_bij_12_something.jpg
now i want to get the file that matches the string up to third _
or i want to get the substring before the third _

example i want to get bik_bij_12 substring from above string in the right corner.


:help:
smartbishal
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu May 22, 2014 9:22 pm

Re: string manupulation

Postby us2rn4m2 » Fri May 23, 2014 12:45 pm

Code: Select all
$string = 'bik_bij_12_something.jpg';
echo substr($string, 0, strrpos($string, '_', 3)); // bik_bij_12


http://www.php.net/manual/en/book.strings.php
us2rn4m2
New php-forum User
New php-forum User
 
Posts: 17
Joined: Thu Aug 09, 2012 1:28 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.