Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7768651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:58:04+00:00 2026-06-01T15:58:04+00:00

This is an example of a mixed, multi-level, irregular array in php: $settings[‘style_formats’] =

  • 0

This is an example of a mixed, multi-level, irregular array in php:

$settings['style_formats'] = array(
  array('title' => 'Center table', 'selector' => 'table', 'styles' => array('margin-left' => 'auto', 'margin-right' => 'auto')),
  array('title' => 'Menu style', 'selector' => 'ul,ol', 'classes' => 'menu'),
  array('title' => 'Layer2', 'inline' => 'div', 'styles' => array('background-color' => 'orange')),
  array('title' => 'Bold text', 'inline' => 'b'),
  array('title' => 'Red text', 'inline' => 'span', 'styles' => array('color' => '#ff0000')),
  array('title' => 'Red header', 'block' => 'h1', 'styles' => array('color' => '#ff0000')),
  array('title' => 'Example 1', 'inline' => 'span', 'classes' => 'example1'),
  array('title' => 'Example 2', 'inline' => 'span', 'classes' => 'example2'),
  array('title' => 'Table styles'),
  array('title' => 'Table row 1', 'selector' => 'tr', 'classes' => 'tablerow1'),
);

I need to find a method to represent and translate this kind of array from string format to php array. The initial string format must be readable and writeable by a human using a text editor. So e.g. it should not be a result of using “serialize”, because “serialize” is a php function (and rather not possible to create by a human) and the string must be possible to create manually in a text editor.

The string will be passed as parameter to a function which will translate it to a php array like the one above.

If it was a simple array, I would use a comma separated string and “explode”. But it is multilevel, so using “explode” won’t work as it will split internal arrays. preg_split also doesn’t look promising because the array is very irregular.

Any ideas how to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:58:05+00:00Added an answer on June 1, 2026 at 3:58 pm

    JSON is one of many solutions, like so: (forgive me for no formatting)

    {"style_formats":[{"title":"Center table","selector":"table","styles":{"margin-left":"auto","margin-right":"auto"}},{"title":"Menu style","selector":"ul,ol","classes":"menu"},{"title":"Layer2","inline":"div","styles":{"background-color":"orange"}},{"title":"Bold text","inline":"b"},{"title":"Red text","inline":"span","styles":{"color":"#ff0000"}},{"title":"Red header","block":"h1","styles":{"color":"#ff0000"}},{"title":"Example 1","inline":"span","classes":"example1"},{"title":"Example 2","inline":"span","classes":"example2"},{"title":"Table styles"},{"title":"Table row 1","selector":"tr","classes":"tablerow1"}]}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This example is taken from w3schools . CREATE TABLE Persons ( P_Id int NOT
I'm trying to find duplicate rows based on mixed columns. This is an example
Im writing this webapp and want to authorize controllers by mixed conditions. For example:
I have this PHP one dimensional array: Array ( [Female--N] => 11 [Male--N] =>
This example uses a StringWriter to hold the serialized data, then calling ToString() gives
This example is simplified a bit, but in my ASP.NET web page in my
this example below works when hover event is trigered and when its not, its
This example working great because here containment is body http://jsfiddle.net/roXon/hMmbK/2/ when i use container
This example shows what I am trying to do: http://jsfiddle.net/Dqjvy/ I would like it
Take this example code (ignore it being horribly inefficient for the moment) let listToString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.