LMSouq

Knowledge Base

Browse Moodle Solutions

Clear

2110 solutions found in server-meltdown

Page 18 of 106
0 votes
3 ans
34 views
Convert timestamp to readable date/time PHP

I have a timestamp stored in a session (1299446702). How can I convert that to a readable date/time in PHP? I have tried srttotime, etc. to no avail.

php-dev Solved
AD
asked 5 months ago by Adamski
0 votes
2 ans
35 views
How to remove the leading character from a string?

I have a input string like: $str = ':this is a applepie :) '; How can I remove the first occurring `:` with PHP? Desired output: `this is a...

php-dev Solved
YU
asked 5 months ago by yuli chika
0 votes
2 ans
31 views
Access first level keys with array_map() without calling `array_keys()`

Is there a way of doing something like this: $test_array = array( "first_key" => "first_value", "second_ke...

php-dev Solved
JO
asked 5 months ago by José Tomás Tocino
0 votes
2 ans
40 views
PHP: merge two arrays while keeping keys instead of reindexing?

How can I merge two arrays (one with string => value pairs and another with int => value pairs) while keeping the string/int keys? None of them will ever...

database Solved
GA
asked 5 months ago by Garrett
0 votes
2 ans
35 views
Truncate a string to first n characters of a string and add three dots if any characters are removed

How can I get the first n characters of a string in PHP? What's the fastest way to trim a string to a specific number of characters, and append '...&#39...

php-dev Solved
AL
asked 5 months ago by Alex
0 votes
2 ans
36 views
List of Big-O for PHP functions

After using PHP for a while now, I've noticed that not all built-in PHP functions are as fast as expected. Consider these two possible implementations of a...

php-dev Solved
KE
asked 5 months ago by Kendall Hopkins
0 votes
2 ans
37 views
How to query all the GraphQL type fields without writing a long query?

Assume you have a GraphQL type and it includes many fields. How to query all the fields without writing down a long query that includes the names of all the fi...

database Solved
BL
asked 5 months ago by BlackSigma
0 votes
2 ans
44 views
Get URL query string parameters

What is the "less code needed" way to get parameters from a URL query string which is formatted like the following? > www.mysite.com/category/su...

database Solved
EN
asked 5 months ago by enloz
0 votes
2 ans
32 views
How should a model be structured in MVC?

I am just getting a grasp on the MVC framework and I often wonder how much code should go in the model. I tend to have a data access class that has methods like...

general-dev Solved
DI
asked 5 months ago by Dietpixel
0 votes
3 ans
33 views
How to get the last element of an array without deleting it?

Ok, I know all about [`array_pop()`][1], but that deletes the last element. How to get the last element of an array without deleting it? Here's a bon...

php-dev Solved
TH
asked 5 months ago by Theodore R. Smith
0 votes
3 ans
26 views
PHP mail function doesn't complete sending of e-mail

<?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from =...

php-dev Solved
US
asked 5 months ago by user3818620
0 votes
3 ans
35 views
What is the difference between client-side and server-side programming?

I have this code: <script type="text/javascript"> var foo = 'bar'; <?php file_put_contents(&#39...

server-admin Solved
DE
asked 5 months ago by deceze
0 votes
1 ans
28 views
Convert a date format in PHP

I am trying to convert a date from `yyyy-mm-dd` to `dd-mm-yyyy` (but not in SQL); however I don't know how the date function requires a timestamp, and I can...

php-dev Solved
MA
asked 5 months ago by matthy
0 votes
2 ans
30 views
How can I connect to a Tor hidden service using cURL in PHP?

I'm trying to connect to a Tor hidden service using the following PHP code: $url = 'http://jhiwjjlqpyawmpjx.onion/' $ch = curl_init();...

php-dev Solved
FR
asked 5 months ago by frosty
0 votes
1 ans
29 views
PHP equivalent of .NET/Java's toString()

How do I convert the value of a PHP variable to string? I was looking for something better than concatenating with an empty string: $myText = $myVar ....

php-dev Solved
AN
asked 5 months ago by Antoine Aubry
0 votes
3 ans
28 views
Fastest way to check if a string is JSON in PHP?

I need a really, really fast method of checking if a string is JSON or not. I feel like this is not the best way: function isJson($string) { ret...

php-dev Solved
KI
asked 5 months ago by Kirk Ouimet
0 votes
1 ans
28 views
What does double question mark (??) operator mean in PHP

I was diving into Symfony framework (version 4) code and found this piece of code: $env = $_SERVER['APP_ENV'] ?? 'dev'; I'm not su...

php-dev Solved
EL
asked 5 months ago by elkolotfi
0 votes
2 ans
32 views
Are PHP short tags acceptable to use?

Here's the information [according to the official documentation][1]: > There are four different pairs of > opening and closing tags which can be...

php-dev Solved
MD
asked 5 months ago by MDCore
0 votes
3 ans
28 views
Check if PHP session has already started

I have a PHP file that is sometimes called from a page that has started a session and sometimes from a page that doesn't have session started. Therefore whe...

php-dev Solved
AR
asked 5 months ago by Arda
0 votes
2 ans
31 views
Laravel Add a new column to existing table in a migration

I can't figure out how to add a new column to my existing database table using the Laravel framework. I tried to edit the migration file using... <...

php-dev Solved
KI
asked 5 months ago by kim larsen