How to customize my php echo code? [closed] - php

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;
?>

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
)

PHP Code Session Not Working [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
My PHP code dosnt seem to be working and I dont Know Why when Ever I Use this code it will Make The whole webpage appear white.I think the problem is Here Somewhereecho Hello, (.$_SESSION['username'], ENT_QUOTES, 'UTF-8');Thanks In Advance
session_start();
if(!isset($_SESSION['user']) && empty($_SESSION['user'])) {
echo '<b>Log In</b>';
}
else {
echo Hello, (.$_SESSION['username'], ENT_QUOTES, 'UTF-8');
echo '</br></b>';
echo '<b>Log Out</b>';
}
When your page goes white, it usually means you have a fatal error in your code and need to check your logs, or turn on error_reporting.
In this case you're missing quotes, have the concatenation a bit messed up, and appear to be missing a function call (probably htmlspecialchars).
Also, you're checking $_SESSION['user'] a few lines before in your code, are you sure you don't mean to echo that here instead of $_SESSION['username']?
I think you want to change that line to:
echo "Hello, " . htmlspecialchars($_SESSION['user'], ENT_QUOTES, 'UTF-8');

Php :Print array inside multi select [closed]

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

How to display HTML code as HTML code using PHP [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 have the PHP code as below:
<?php
echo "<tr></tr>";
//ouput I want : <tr></tr>
?>
When Output I want to display <tr></tr>.But I don know whitch function that I should use for this,anyone know help me please,thanks
Try with htmlentities like
<?php
echo htmlentities("<tr></tr>");
?>
Follow this LINK
You can also make use of htmlentities()
<?php
echo htmlentities("<tr></tr>");
?>
Try this
$output = htmlspecialchars("<tr></tr>", ENT_QUOTES);
Use htmlentities
<?php
echo htmlspecialchars('<tr></tr>');
?>

PHP echo same function twice [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 need to echo a paging function twice,
echo blaetterfunktion($seite, $wieviele_seiten);
content
echo blaetterfunktion($seite, $wieviele_seiten);
I guess that would burden the server twice?
What can I do to have the server burdened just once and still echo it twice?
Place the result of the function in a variable:
<?php
$result = blaetterfunktion($seite, $wieviele_seiten);
echo $result;
?>
content
<?php
echo $result;
?>
Save it to a variable:
<?php
$variable = blaetterfunktion($seite, $wieviele_seiten);
echo $variable;
?>
content
<?php
echo $variable;
?>

Categories