I have stored db URL like this ../../images/aprilfoolcards/lovefoolsday.gif, ../../images/navratri/navratri1.gif
want to know how to get category like aprilfoolcards, navratri in PHP.
Regards
Raja
PHP SUBSTRING
Moderator: General Moderators
Re: PHP SUBSTRING
Code: Select all
<?php
//$subject = "../../images/aprilfoolcards/lovefoolsday.gif";
$subject = "../../images/navratri/navratri1.gif";
$pattern = '#\.\./\.\./([^/]+)/([^/]+)/([^/]+)#';
preg_match($pattern, $subject, $matches);
print_r($matches);
Re: PHP SUBSTRING
Store the string how you need it to be retreived, instead of storing the URL. You can generate the URL on each page view.
Re: PHP SUBSTRING
just use explode ('/',$url);
Re: PHP SUBSTRING
A little more clarification would be nice.