php - Nesting inner array as value in pre-existing multi-dimensional array -


i have array called:

$fragment = array($fragment); 

which has following 3 values:

  1. ["<div class=\"alert alert_error mt20\"><a class=\"js-alert-close close\"><\/a>please enter title <\/div>"]
  2. ["<div class=\"alert alert_error mt20\"><a class=\"js-alert-close close\"><\/a>enter valid source url (e.g. http:\/\/en.wikipedia.org\/wiki\/penguins) <\/div>"]
  3. ["<div class=\"alert alert_error mt20\"><a class=\"js-alert-close close\"><\/a>please choose category <\/div>"]

i want merge array array (into 'fragment' key) looks like:

$toreturn = array(     'status' => $status,     'formdata' => $formdata,     'inputs' => $inputs,     'fragment' => $fragment ); 

but every time so, adds first value of $fragment is:

  1. "<div class=\"alert alert_error mt20\"><a class=\"js-alert-close close\"><\/a>please enter title <\/div>"

how can add 3 values $fragment $toreturn array instead?

you can create 1 long string 3 array entries concatenating them, e.g. popular implode­docs function:

$fragment = implode("", $fragment); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -