Solved

foreach in array

Posted on 2011-02-12
4
313 Views
Last Modified: 2012-05-11
Hi guys,

I need to create an array and then serialize it and save to DB. My idea is something like that:

$header=array(
    foreach ($this->lang->lang_list() as $_lang => $_language)
        {
        $_lang => $this->input->post('header_'."$_lang"),
        }
    );

it be like:

$header = array('en' => 'english header from POST',
'ru' => ' russian header from POST',)

but I have no idea how to use foreach which should loop the list of available languages in this situation.
0
Comment
Question by:NiconPhantom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Sudaraka Wijesinghe earned 250 total points
ID: 34878829

$header=array();

foreach ($this->lang->lang_list() as $_lang => $_language)
{
	$header[$_lang] = $this->input->post('header_'.$_lang);
}

//Show the created array
var_dump($header);

Open in new window

0
 

Author Comment

by:NiconPhantom
ID: 34878849
Thank you sudaraka, I'll test that in 5-10 min, but it looks like 250p is yours :-)
0
 

Author Closing Comment

by:NiconPhantom
ID: 34878941
Thank you Sudaraka that's what I need!
0
 
LVL 18

Expert Comment

by:Sudaraka Wijesinghe
ID: 34878964
Glad to help. Thanks for the points.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I split a variable 19 42
center div inside another div 2 30
PHP MYSQLI Connection in Function in a class 4 26
Load string Array from file 23 37
This article discusses four methods for overlaying images in a container on a web page
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question