Php :Print array inside multi select [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I want to print the below array inside multi select ;
this is my html code for multi select .
<select name="user_email[]" size="17" style="margin-top:8px; height:256px;" multiple="multiple" class="wiidth300px textBoxStyle removePadding removeMargin externale_users" value="">
This is my array:
$test =array ( [0] => abc#example.com [1] => def#example.com );
i want to print the elements of array html multi select.

<select multiple>
is what you do to select more than one.
http://www.w3schools.com/tags/att_select_multiple.asp

You have to work a lot
you can do this like following:
<?php $array = Array ('kagava,kagava#manutd.com','evra,evra#manutd.com')?>
<select>
<?php
foreach($array as $index=>$email)
{
?>
<option value="<?php echo $email?>"><?php echo $email?></option>
<?php }?>
</select>
this will work surely

Related

preg match for known value plus 7 charecters [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Can anyone help me get the value of IFC/USD 0.00001031 from the webpage http://infinitecoin.com.
I need to grab the value after IFC/USD..
The way I thought to do it was to:
$file_string = file_get_contents('http://infinitecoin.com');
preg_match('/IFC/USD plus next 11 charecters', $file_string, $title);
$value = $title[1];
echo $title_out ;
But im not sure how to ask PHP to find IFC/USD then return the next 11 characters after that.
If I could accomplish this, my task would be solved..
Any help would be great.
Thank you
Jason
$output = array();
preg_match("/(?<=IFC\/USD\s)[\d\.]+/", 'IFC/USD 0.00001015', $output);
$output will look like this:
Array
(
[0] => 0.00001015
)

How to customize my php echo code? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i echo some data in the Author Box of my Wordpress Theme with:
<?php echo $user_info->new_user_blond; ?> <?php echo $user_info->new_user_brown; ?> <?php echo $user_info->new_user_red; ?>
The users can check one ore more checkboxes. If a user checks all 3 Checkboxes for example the result shows up in the author box as:
blond brown red
Everthing works fine, but please help me to change my code to achive this result:
blond, brown, red
When i put a "," between the codes it shows me the desired result. BUT if a user
only checks on checkbox it shows me:
blond,,
I would be very pleased if you would support me :)
<?php
$userarr = array(
$user_info->new_user_blond,
$user_info->new_user_brown,
$user_info->new_user_red,
);
$result = implode(',',array_filter($userarr));
echo $result;
?>

Getting value from JSON [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am struggling to get pull the correct values
I am trying to get the following
packages>items then loop through the ids
{"id":1,"title":"Barnsley","slug":"barnsley","packages":[{"id":1,"title":"Group PACKAGE 1","items"
{"id":9,"title":"Guiness","band_a":null,"band_b":null,"band_c":null,"band_d":null,"band_e":null,"band_f":null,"band_g":null,"band_h":null,"band_i":null,"band_j":null,"variations":null},
{"id":10,"title":"John Smith","band_a":null,"band_b":null,"band_c":null,"band_d":null,"band_e":null,"band_f":null,"band_g":null,"band_h":null,"band_i":null,"band_j":null,"variations":null},
{"id":22,"title":"Chicken Cheese and Bacon Melt","band_a":4.5,"band_b":4.75,"band_c":5.0,"band_d":5.25,"band_e":null,"band_f":null,"band_g":null,"band_h":null,"band_i":null,"band_j":null,"variations":null}],"additional_items":null,"event_types":null}]}
Your JSON isn't valid. You're missing two characters :[ that declare the items array. After fixing the JSON (check it on jsonlint.com) you can iterate over the item IDs like so:
$obj = json_decode($str);
foreach($obj->packages[0]->items as $item)
{
echo $item->id;
}
If there could be more than one package you can iterate those too:
foreach($obj->packages as $package)
{
foreach($package->items as $item)
{
echo $item->id;
}
}

How to display stored array from database [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
This is how I'm storing the array into my database (part of a bigger code):
echo '<form action="" method="post">';
for ($count = 0; $count < $_GET["entries"]; $count++)
{
echo 'Enter a beginning to ending date for the week: <input type="text" name="week"><br/>';
}
echo '<input type="submit" name="submit"></form>';
It's within a tag, hence the echo.
I checked my database and I can see the first date, so it is being stored.
This is how I'm displaying my array (doesn't seem to work):
Where am I going wrong? Is it just the output or the input as well? I would really appreciate any suggestions for a possible answer. Thanks.
Current Specific Weeks: <?php
foreach ($currentWeeks as $currentWeeks)
{
echo "{$currentWeeks}\n";
}
Foreach mistake. You're using $currentWeeks for both the array and the element.
Use different variable name in foreach loop
foreach ($currentWeeks as $week)
^^^^^ // here
{
echo "{$week}\n";
}

Call variable inside array element [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Is it possible to read array element using variable?
I'd like to set $vid in one place depending on the configuration, and then use multiple times i.e. $detailrow["customfields1"];
I want to do this:
$vid = 1;
$detailrow["customfields$vid"];
But no response.
Tried:
$detailrow["customfields{$vid}"];
$detailrow['customfields'.$vid];
but result is the same.
Of course you can do this:
$tmp=array("name" => "foo", "bar" => "name", "field1" => "value1");
You could then do sth. like
echo $tmp["name"];
will print 'foo'
echo $tmp[$tmp["bar"]];
will also print 'foo'
Or
$i=1;
echo $tmp["field".$i]
will print 'value1'
i have tested your code and its working
<?php
$vid = 1;
$detailrow["customfields1"]="rajeev";
echo $detailrow["customfields$vid"];
?>

Categories