I need to display html using json encode [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a form and am using json encode. It displays like the below.
[{"approveNight":"A","approve":"A","Comments":"bbb","Email":"email#email.com"}]
I am using this, but I would like it to display html. What am I missing?
<?php
$data = array($jsonData);
echo json_encode($data);
?>
I would like it to display as
Approve: yes or no
Approve: yes or no
comments: the comments
email: email address that they typed in

Try this and see if this helps:
$arrValues= json_decode($data);
print 'Approve: '.($arrValues['approve']=='A' ? 'Yes' : 'No').'<br />'
. 'Comments: '.$arrValues['Comments'].'<br />'
. 'Email: '.$arrValues['Email'].'<br />'
. 'Approve Night: '.($arrValues['approveNight']=='A' ? 'Yes' : 'No');

Related

Like selected file name in PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have a file image with the name :
35210001.jpg
And I want to move the file to another folder.
What is the solution to handle the "LIKE" in PHP like Query in MySQL because the filename indicator obtained from the request to move is only :
3521
This is mycode :
$name = "35210001.jpg";
$date = date("YmdHis");
File::move('C:/xampp/htdocs/test/test_media/' . $name, public_path('test_move' . $date . '.jpg')); public_path('test_move' . $date . '.jpg'));
What you are looking for is the glob function, here is the doc
Exemple from doc :
foreach (glob("*.txt") as $filename) {
echo "$filename occupe " . filesize($filename) . "\n";
}

Convert plain text URLs to HTML hyperlink in PHP [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a form in HTML, i ask the user to enter a url, once that happens it comes back in plain text in PHP. What i want to happen is that when they enter their URL and submit the link that they have entered will become clickable. This is the code i have. I hope this helps.
<?php
$firstname = $_POST['firstname'];
$course = $_POST['course'];
$projecturl = $_POST['projecturl'];
echo "<p>You are <span class='textblue'> $firstname</span> and ";
echo "your course at the college is: <span class='textblue'> $course </span></p> ";
echo "your project url is: <span class='textblue'> $projecturl</span></p> ";
echo "a href=’google.com’>Google</a>” .
?>
Try to use parse_url, for example:
<?php
$url = '//www.example.com/path?googleguy=googley';
var_dump(parse_url($url));
?>
If you want to search more about this code:
https://www.php.net/manual/en/function.parse-url.php
change echo statements like this
echo "<p>You are <span class='textblue'>.'"$firstname"'.</span> and ";

How will make variable to do_shortcode value? i want to change shortcode value like (category="others") how it possible? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to make variables of these red block parts
(screenshot).
PHP code:
echo do_shortcode('[product_category category="others" per_page="12" columns="4"]');
You can directly insert variable values in a "" delimited string in PHP.
$cat = "some_category";
$per = 20; // some number
$col = 10; // some number
echo do_shortcode("[product_category category=\"$cat\" per_page=\"$per\" columns=\"$col\"]");
If you still want to use a '' delimited string, you need to append values together.
echo do_shortcode('[product_category category="' . $cat . '" per_page="' . $per . '" columns="' . $col . '"]');

Get youtube info with php [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want get in my site this text info:
http://gdata.youtube.com/feeds/api/videos/IyBvgi4ZlbM
when the video is not found.
how i can writte the code?
i don't understand here:
https://developers.google.com/youtube/2.0/developers_guide_php?csw=1
thank you!
You can try checking the video is available or not with headers:
$headers = get_headers("http://gdata.youtube.com/feeds/api/videos/".$row['youtube']);
if (!strpos($headers[0], '200'))
{
echo "Video is not found";
}
Try this ;)
<?php
$headers = get_headers('http://gdata.youtube.com/feeds/api/videos/IyBvgi4ZlbM');
$is_ok = substr($headers[0], 9, 3) == 200;
if($is_ok){
echo 'Video is OK :)';
}
else{
echo 'Something is wrong :(';
}

add html as option to a variable [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have this code :
$variable_name = bla bla bla;
I want to add to this variable this code :
<a class="screenshot" rel="<?php echo $baseurl.$this->row->image; ?>" >
<div class="photo"></div>
</a>
Can somebody PLEASE help?
Thank you
You assign it to your variable like any other string. However, since you are already in php mode, you have to remove <?php ?>, and use string contatenation operator . to include $baseurl.$this->row->image
$variable_name = '<a class="screenshot" rel="' . $baseurl.$this->row->image . '" >
<div class="photo"></div>
</a>';

Categories