Solved

foreach in array

Posted on 2011-02-12
4
308 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
  • 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now