colap Posted March 27, 2012 Share Posted March 27, 2012 Given array Array ( [Post] => Array ( [title] => new with has many through for tags [body] => hello tags [category_id] => 11 [tags] => one two three [mark] => 1 ) ) I need to make an array something like this: Array ( [Post] => Array ( [title] => new with has many through for tags [body] => hello tags [category_id] => 11 [mark] => 1 ) [Tag] => Array ( [0] => Array( [name] => one ) [1] => Array( [name] => two ) [2] => Array( [name] => three ) ) ) How can i make it? Quote Link to comment https://forums.phpfreaks.com/topic/259808-how-can-i-make-two-array-slicing-an-array/ Share on other sites More sharing options...
Psycho Posted March 27, 2012 Share Posted March 27, 2012 Is it an array with just one record or would you have multiple "POSTS" in the array? If you have multiple posts, the output format will not work - or, at least, you need to show an example of what you want for a mufti-record output because it doesn't make sense to me. Plus, why would you want to make the tags elements separate subarrays with only one element. That really makes no sese. I can see making the tags a subarray, but not with each one as a single element array. I was going to provide a solution, but after looking at what you are really asking for I would rather see "why" you think you need that. I think we can probably provide a better solution for processing the data than what you may be doing now. Quote Link to comment https://forums.phpfreaks.com/topic/259808-how-can-i-make-two-array-slicing-an-array/#findComment-1331594 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.