hey i am new to Joomla and always a learner please some one help me that i am exploding the string which i am retrieving from the database of Joomla com_content. it is the path of the image. after fetching the data i have got.
$img="images\/sample-image-big.png"
after that i am exploding it to get only the name of the image so i have removed / after that the result is coming,
Array (
[0] => "images
[1] => sample-image-big.png" )
the problem is that the array[1]=> should be only sample-image-big.png but the " is coming why i want it to remove it , ihave tried all types of explosion but no change , please help me i will be very much thankful to u.
$img="images\/sample-image-big.png"
stripslash your string
$img=stripslashes($img)// this will give you "images/sample-image-big.png"
now various ways to get what you need. Simplest for me:
$img = str_replace('"images/', '', $img); // will give sample-image-big.png"
$img = str_replace('"', '', $img); // will give sample-image-big.png
do like this
<?php
$img="images\/sample-image-big.png";
$img=explode("\/",$img);
print_r($img);
output:
Array
(
[0] => images
[1] => sample-image-big.png
)