Seperate a String variable with the delimiters


I have been trying to fix a gallery of images in my project. Atlast i have landed up with a solution we can get the collection of a images Url seperated with commas and then make it stored in the array variable and retrieve it back.

<?php 
$image=get_post_meta($post->ID, 'custom field name', true);
$img=explode(',',$image);
for($i=0;$i<sizeof($img);$i++)
{
?>
<a href="<?php if((($img[$i] == substr($img[$i],0,57).''.'.jpg'))) { echo substr($img[$i],0,57).''.'_b.jpg'; } else { echo substr($img[$i],0,57).''.'_b.jpg'; } ?>"><img src="<?php if((($img[$i] == substr($img[$i],0,57).''.'.jpg'))) { echo substr($img[$i],0,57).''.'_m.jpg'; } else { echo substr($img[$i],0,57).''.'_m.jpg'; } ?>" style="width:172px;"/></a>
<?php
}
?>

Thanks for my dream one.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s