I'm attempting to split a .php file into several parts using bash, and I can't seem to figure out a way to split it based on the header.
I will not be changing anything within the .php file, only taking the information from it.
I have looked into using split
, but it doesn't seem to have the attributes that I am looking for.
As an example, the file behaves like this:
'Josh-per' => array(
Height=60
Weight=90
Age=20
),
'Katie-per' => array(
Height=55
Weight=110
Age=45
#...etc
This isn't the exact code, but is much more basic but retains the same idea. Each "name" ends with -per, and then holds information relating to that person inside it.
What I'd like it to do is turn each Array into its own file, named Josh.foo
and Katie.foo
With the inside being
Height=60
Weight=90
Age=20
=========================
Ok, I was a bit confusing initially and will try to remedy that, but I'll keep the old one up anyway just in case.
So, I was given a .php with multiple classes, starting with $NAME-per, but it is not unique in the file. I am not going to be changing anything within the .php, as it is autogenerated with a lot more information than what I am presenting.
Here is a better representation of what is in the file, named sources.php
<?php
$config = array(
'Josh-per' => array(
'certificate' => 'null.cert',
'key' => 'something-per.key',
'site' => 'website.com',
),
'Katie-per' => array(
'certificate' => 'notnull.cert',
'key' => 'testkey.key',
'site' => 'fakesite.com'
#...etc
In summary, what I am trying to do is make Josh-per
into a new file called Josh.sources
, and Katie-per
into Katie.sources