0

Hi Folks !!


i have a string like this. "../images/gallery/New-Goa-Park-in/86ffbca77051448489aec640d288153a.jpg" from this path i want only ../images/gallery/New-Goa-Park-in/ how can i do it?

Please help

Thanks.

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by somedude3488
0

Hi Folks !!


i have a string like this. "../images/gallery/New-Goa-Park-in/86ffbca77051448489aec640d288153a.jpg" from this path i want only ../images/gallery/New-Goa-Park-in/ how can i do it?

Please help

Thanks.

<?
	$str = "../images/gallery/New-Goa-Park-in/86ffbca77051448489aec640d288153a.jpg";
	$str_exploded = explode("/", $str);
	for($i = 0; $i <= 3; $i++)
	{
		$new_str .= $str_exploded[$i]."/";
	}
	echo $new_str;
?>
0

1:get the index of '/' from that's String
2:stor the above index
3 search for another '/'
id there ,, jump to step 1
other wise copy subString from index 0 to latest index of '/'

just get the latest '/' within assumed string

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.