0

my array in DB looks like this:

a:2:{i:0;s:6:"first";i:1;s:9:"second";}

So output is like:

1 => first
2 => second

How can I update eg. only 1st value?

2
  • I'm not sure what you mean by array in DB. Could you explain a bit more about that? Commented May 17, 2016 at 10:35
  • a:2:{i:0;s:6:"first";i:1;s:9:"second";} <- this is a value in column meta_value. When I add new position it will be eg. a:3:{i:0;s:6:"first";i:1;s:9:"second";i:2;s:5:"third";} Commented May 17, 2016 at 10:39

1 Answer 1

4

Your string in your DB is a serialized array. You first need to unserialize it and then you can modify the values.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.