PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 1, 2022

[FIXED] How to only get last value of array in php in shopify

 July 01, 2022     api, curl, php, shopify     No comments   

Issue

I am creating APP for Shopify and I need the last fulfillment id of an order.

This is my code

if($value['fulfillment_status'] == 'fulfilled') {
 foreach($value['fulfillments'] as $id) {
  echo $id['id'].'<br>';
 }
}

The output is

3549057974422
3555100033174
3557460050070
3560109277334
3560268103830
3560845475990
3561173024918

I only want to save or get the last fulfillment id value which is

3561173024918

How to do this ?

Regards


Solution

You can use end().

echo end($value['fulfillments'])["id"];


Answered By - user6731413
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing