Level 10
Looks like the file has the fields separated by a tab, If you specify the proper separator the MRS B ADAMS will be one element instead of three.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a text file and I want to make an array form the line below.
8295 MRS B ADAMS 13469.58 0.00 13479.58 1456.43 3452.16
the desired output is
[8295, MRS B ADAMS, 13469.58, 0.00, 1456.43, 3452.16]
the problem is the spaces are not regular and I want the name MRS N ABRAMS to be one word. I have tried regex but it also splits the name MRS N ABRAMS into three elements.
Please or to participate in this conversation.