Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

foreach in array

Posted on 2011-02-12
4
Medium Priority
?
317 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 1000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

963 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