PHP -modify value of last accessed element in multidimensional associative array -


i reading gedcom-formatted family tree flat file, , producing array data staging table. if encounter values conc <some value>, then, instead of adding element, need append <some value> value of last element inserted (regardless of dimension depth).

i tried current(...) etc work multidimensional associative array?

please consider following element in array:

[@n163@] => array ( [indi] => array ( [text] => data of person) )  

if next line reads "1 conc including profession"

instead of adding line such

[@n163@] => array (                   [indi] => array ( [text] => data of person)                   [indi] => array ( [conc] => including profession) )   

i array follows:

[@n163@] => array (                  [indi] => array ( [text] => data of person including profession) ) 

what have researched far:

end($thearray) set pointer last inserted element followed $thearray[key($thearray)] = .... update element.

but did not method work multidimensional arrays and/or became messy.

and:

merging 2 arrays using e.g. += notation, seems overwrite new element, not affect last one, if keys same

and:

examples foreach calls, not in case.

hope can shed light... many thanks!

when adding $array[@n163@][indi][text] = 'smtng'; can save position

$pos = &$array[@n163@][indi][text]; 

and if need concatenate, write

$pos .= "concate line"; 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -