mardi 24 février 2015

Transform string into array in php

I'm sure this has been answered, but I have no idea how to research it. This is my string



[value1, value2, value3, ..., valueN]


and I'd like to know if there's a native function that transform it into a simple array



array('value1', 'value2', 'value3', ..., 'valueN');


Let it be clear that I'm looking to know if there's something already written that do it, that is, another approach other than strpos('[') and implode(',').




Edit


Sorry I haven't given much attention to this question because I'm working non-stop on this project that required me to ask this question. Regarding the last comment, I'd like to add here that that is no an issue, but how it was planned. I decided to make the arrays look exactly like JSON arrays because I wanted an easy function to undo it. Here is my INI file.



; Default Pages
user = all
wordpress = all
home/welcome = visitor
home/customer = visitor
home/new = visitor
home/signup = visitor

; User
user/panel = '["user", "worker", "customer", "company", "staff", "ruler", "gifter", "support", "salesman", "scorer", "recorder", "reporter", "deliverer", "manager", "admin"]'
user/profile = user
user/password = user
user/support = user

; Reporter
user/report = reporter

; User/Customer
user/customer/voucher = customer
user/customer/history = customer
user/customer/ticket = customer
user/customer/profiling = customer

; User/Staff
user/staff/customer = recorder

; User/Manager
user/staff/score = scorer
user/staff/voucher = deliverer

user/manager/shop = '["salesman", "manager"]'

user/manager/staff = manager
user/manager/ticket = manager

Aucun commentaire:

Enregistrer un commentaire