1

I have these lines stored in an array variable

pl_id=MDR_PLZ
ln_id=01N
dt_concluded=20191106115958796600
tx_seq_nr=122586
ts_seq_nr=1078
us_id=c0507387

Lines are more than displayed here, the point is .. I need to convert this one array into further arrays so that i can use this data. I tried to use explode to convert them into array but its no use. I tried converting all these lines to single line by using preg_replace, trim, so that after that i can save it to variable and then explode it to get array but it did not work ..

Any help will be appreciated.

3
  • You mean $pl_id = 'MDR_PLZ' like this? Commented Nov 8, 2019 at 6:37
  • What does your expected output look like? Commented Nov 8, 2019 at 6:40
  • no need to reinvent the wheel. use parse_ini_string Commented Nov 8, 2019 at 6:46

1 Answer 1

2

You can do it with, Demo

print_r(array_map(function($v){return explode(PHP_EOL,$v);},$array));
Sign up to request clarification or add additional context in comments.

2 Comments

this was awesome ... Thanks Roofe .. however I have no idea about PHP_EOL, i tried to understand it but failed .. if you can please kindly tell what it is .. that will be awesome .. Bless you Roofe
@Numan PHP_EOL stands for end of line, is a constant define in php Core_d.php.

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.