0

Hello I have this array :

array(3) {
  [0]=>
  string(2) "35"
  [1]=>
  string(2) "33"
  [2]=>
  string(2) "50"
}

That I obtain using this :

$groupstring = $_POST['groupstring'];
$groupstring =  stripslashes($groupstring);
$blah = unserialize($groupstring);

var_dump($blah);

this is what's inside the var groupstring : a:3:{i:0;s:2:"35";i:1;s:2:"33";i:2;s:2:"50";}

I want to insert a new value for example 38 at the end. I tried array_push($array, '38') but it failed I understand there is an index. what would be the best way to do it? thanks much!!

2
  • Could you provide the code that fails? Commented Jun 6, 2013 at 20:57
  • @Guillaume I updated the code Guillaume Commented Jun 6, 2013 at 21:18

1 Answer 1

1
$groupstring = $_POST['groupstring'];
$groupstring =  stripslashes($groupstring);
$blah = unserialize($groupstring);

$blah[] = 38;
var_dump($blah);
Sign up to request clarification or add additional context in comments.

2 Comments

"array_push($blah, 38);" works too... so I still don't understand what was the problem at first...
Guillaume I had an undefined variable instead of $fid I was using $id. It was my fault sorry.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.