I am trying to replace the keys of quite a large array so that I only get a spcific piece of data from it. My client pastes in a set of data in a specific format into a text are which is then loaded into a series of columns in a table like so:
textarea data would be like:
rp1=1, rp2=3, rp4=5 etc etc
If I do a var dump on the post I get this:
array(33) { [0]=> string(2) " 8" [1]=> string(5) "RP2=7" [2]=> string(5) "RP3=9" [3]=> string(6)...
What I am trying to do isjust give me the figure from the key so for instance if you look at the var_dump I did I hit the first key with a string replace so I only get 8 in the array series. I am wanting to know a way to attack all of them as some of the strings contain 4 characters and some 5. so like rp1=1 and rp10=2.
They way I get the data from a textarea into an array is by doing this:
$stenData = explode(', ', $_POST['stenData']);
RP[0-9]+=. You can use that preg_replace here, too.array(33) { [0]=> string(2) "8" [1]=> string(5) "3" [2]=> string(5) "4" [3]=> string(6)...$stenData = array_map('trim',explode(', ',preg_replace('#(RP[0-9]+=)#','',$_POST['stenData'])));