I'm stuck and I just need a pointer. I have this string with special characters retrieved from db and i want to segment it to many strings or arrays and in the process i want to exchange those characters with "()". |p| stands for parent. |c| child.
Example sentence is :
my beautiful car is awesome
*where my , beautiful and car have a parent-child relationship.
The pattern for it :
|p|my|c||p|beautiful|c||c||p|car|p|is|p|awesome
In case you need to see the original array:
Array
(
[0] => Array
(
[name] => |p|my
[parent_id] => 0
[child] => Array
(
[0] => Array
(
[name] => |c||p|beautiful
[parent_id] => 1
[child] => Array
(
[0] => Array
(
[name] => |c||c||p|car
[parent_id] => 2
)
)
)
)
)
[1] => Array
(
[name] => |p|is
[parent_id] => 0
)
[2] => Array
(
[name] => |p|awesome
[parent_id] => 0
)
)
The ultimate goal after segmenting and replacement is: ((My(beautiful(car)) (is)(awesome))