1

I am trying to retrieve the specific value in a array but it says undefined

below is the sample array

[customfield_10007] => Array ( [0] => com.atlassian.greenhopper.service.sprint.Sprint@13e19f2[id=70,rapidViewId=27,state=CLOSED,name=Sprint 1,goal=,startDate=2015-11-16T14:53:46.428+05:30,endDate=2015-12-11T14:53:00.000+05:30,completeDate=2015-12-16T11:43:21.799+05:30,sequence=70] )

I wanted to retrieve state=CLOSED. Could you please let me know how I can achieve this

Thanks in Advance,

3
  • 2
    Your state key is part of string and not array itself. You might to check each value of array if it contains state=CLOSED using strpos or similar function Commented Feb 28, 2017 at 8:18
  • 1
    seems you have a string not an array .. Commented Feb 28, 2017 at 8:18
  • 1
    My guess is you did something wrong when you were interpreting the array and ended up with the wrong structure. Commented Feb 28, 2017 at 8:19

1 Answer 1

1

Starting from your array, you can cycle it with this snippet

foreach ($array as $string) {
    preg_match('/state=(\w+)/', $string[0], $matches);
    var_dump($matches);
}

It should be clear. Then you can do what you need with $matches.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks. will the preg_match removes the special characters.?
what do you mean? in $matches you'll have to different string, one completed, as you asked and one just saying COMPLETE
sometimes state=Completed or state=Completed_success_0904 . So I want whatever the value given to state
basically I want everything under state=AB Sprint 13, till the comma. It may contain special characters space and alphanumeric.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.