Solved

foreach in array

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

735 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