PHP explode

I have a PHP query return that looks like this:
Custom OEM Diode Laser Products 1
 {filedir_51}IMG_CustomOEMDiodeLaserProducts1_850x850_0915.jpg Custom OEM Diode Laser Products 2{filedir_51}IMG_CustomOEMDiodeLaserProducts2_850x850_0915.jpg

The return is a list of image files in a field, I only want the last on;

How do I just take the last part?

The field is field_id_1141
My PHP looks like this:
ini_set('display_errors', 1);

$cw ='';
$pulsed = '';
$pulsednp = '';

	if($action=="laser_finder") {
		$cw = $_GET['cw'];
		$pulsed = $_GET['pulsed'];
		$pulsednp = $_GET['pulsednp'];
		$laser_query = ee()->db->select('field_id_1091, field_id_1141')
		->where('field_id_3731', $cw)
		->or_where('field_id_3731', $pulsed)
		->or_where('field_id_3731', $pulsednp)
		foreach($laser_query->result_array() as $row){
   			echo $row['field_id_1091'].'<br />';
   			echo '<img src=".$row['field_id_1141']." />'<br />';

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Peos JohnPHPCommented:
Please check if this is helpful
$string = ' {filedir_51}IMG_CustomOEMDiodeLaserProducts1_850x850_0915.jpg Custom OEM Diode Laser Products 2{filedir_51}IMG_CustomOEMDiodeLaserProducts2_850x850_0915.jpg

$exp = explode('{filedir_51}',$string);

echo '<pre>';

Open in new window

This retuns
    [0] =>  
    [1] => IMG_CustomOEMDiodeLaserProducts1_850x850_0915.jpg Custom OEM Diode Laser Products 2
    [2] => IMG_CustomOEMDiodeLaserProducts2_850x850_0915.jpg

NerdsOfTechTechnology ScientistCommented:
Please repeat what field_id_1141 contains as it was word wrapped in the question.

Are the images packed into one field; if so, is there any delimiter in the field (such as a comma) that separates the list of images
rgranlundAuthor Commented:
The images are all in one field, with a space between each image.  The image loocation starts with  {filedir_51}
NerdsOfTechTechnology ScientistCommented:
change line 24 to:
echo '<img src=". array_pop(explode(' ', $row['field_id_1141'])) ." />'<br />';

Open in new window

explode separates the list into array elements based on a delimiter; a space in your case ' '.

array_pop returns the last element in the list

assuming there are no spaces other than the delimiter in the field, this should work

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.