ItGo.me Focus on IT Recommend

Home > php - how to get string from array in cakephp?

php - how to get string from array in cakephp?

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1073

2020阿里云最低价产品入口,含代金券(新老用户有优惠),
入口地址https://www.aliyun.com/minisite/goods

I want to insert data in cakephp from add from. I got array in $this->request->data['ProductValue'] at controller. My array is:

Array
(
[0] => Array
    (
        [title] => Deepak1
        [value] => Option1
    )

[1] => Array
    (
        [title] => Deepak2
        [value] => Ans1, Ans2, Ans3, Ans4

    )

[2] => Array
    (
        [title] => Deepak3
        [value] => Product1
    )

[3] => Array
    (
        [title] => Deepak4
        [value] => Radio1
    )

)

but i need this type of array:

Array
(
[0] => Array
    (
        [title] => Deepak1
        [value] => Option1
    )

[1] => Array
    (
        [title] => Deepak2
        [value] => Array
            (
                [0] => Ans1
                [1] => Ans2
                [2] => Ans3
                [3] => Ans4
            )

    )

[2] => Array
    (
        [title] => Deepak3
        [value] => Product1
    )

[3] => Array
    (
        [title] => Deepak4
        [value] => Radio1
    )

)

please tell me how to do this...

Recommend:php - Embedded arrays in MongoDB with CakePHP

mework. I have the following set: A user model,for users,which is saved as json in mongodb. One user's record is called interests,which requires an embedded array with json data. The structure is the following: {'username' => 'something',

php arrays cakephp pdo cakephp-bake
|
  this question
edited Sep 22 '14 at 6:36 Morix Dev 1,639 10 38 asked Sep 22 '14 at 5:55 Deepak Chittora 1      just explode it on , –  mithunsatheesh Sep 22 '14 at 6:01

 | 

1 Answers
1

function prepare(&$List) {
 foreach($List as &$element) {
  $tmp = explode(', ', $element['value']);
  if(count($tmp) <= 1) { continue; }
  $element['value'] = $tmp;
 }
}

prepare($YourArray);

|
  this answer
edited Sep 22 '14 at 6:50 answered Sep 22 '14 at 6:01 John V 499 3 9

 | 

Recommend:php - Bake every table in CakePHP

model and controller for each one individually. I would like to bake all of the tables at the same time with something like the .xml files in Hibernate that tells it the limitations on fields so that I don't have to go through every column

------splitte line----------------------------