Solved

foreach in array

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

617 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