LMSouq

Knowledge Base

Browse Moodle Solutions

Clear

366 solutions found in php-dev

Page 8 of 19
0 votes
2 ans
34 views
Converting string to Date and DateTime

If I have a PHP string in the format of `mm-dd-YYYY` (for example, 10-16-2003), how do I properly convert that to a `Date` and then a `DateTime` in the format o...

php-dev Solved
CH
asked 5 months ago by Chris Pinski
0 votes
3 ans
31 views
How to get last key in an array?

How can I get the last key of an array?

php-dev Solved
AJ
asked 5 months ago by ajsie
0 votes
2 ans
28 views
How to remove duplicate values from a multi-dimensional array in PHP

How can I remove duplicate values from a multi-dimensional array in PHP? Example array: Array ( [0] => Array ( [0] => abc...

php-dev Solved
IA
asked 5 months ago by Ian
0 votes
2 ans
35 views
How can I handle the warning of file_get_contents() function in PHP?

I wrote a PHP code like this $site="http://www.google.com"; $content = file_get_content($site); echo $content; But when I remove &...

php-dev Solved
WA
asked 5 months ago by Waseem
0 votes
2 ans
33 views
Deleting all files from a folder using PHP?

For example I had a folder called `Temp' and I wanted to delete or flush all files from this folder using PHP. Could I do this?

php-dev Solved
GE
asked 5 months ago by getaway
0 votes
2 ans
29 views
How do I read any request header in PHP?

How should I read any header in PHP? For example the custom header: `X-Requested-With`.

php-dev Solved
SA
asked 5 months ago by Sabya
0 votes
2 ans
32 views
How to enable PHP short tags?

I have a web application on a Linux server which starts with `<?` I needed to copy this application to a windows environment and everything is working fin...

php-dev Solved
SE
asked 5 months ago by seedg
0 votes
2 ans
30 views
Remove new lines from string and replace with one empty space

$string = " put returns between paragraphs for linebreak add 2 spaces at end "; Want to remove all new lines from st...

php-dev Solved
JA
asked 5 months ago by James
0 votes
2 ans
27 views
List all files in one directory PHP

What would be the best way to list all the files in one directory with PHP? Is there a $_SERVER function to do this? I would like to list all the files in the u...

php-dev Solved
SH
asked 5 months ago by Shadowpat
0 votes
3 ans
27 views
String comparison using '==' or '===' vs. 'strcmp()'

It seems that PHP's `===` operator is case sensitive. So is there a reason to use `strcmp()`? Is it safe to do something like the following? if ($...

php-dev Solved
JI
asked 5 months ago by Jiew Meng
0 votes
2 ans
37 views
WRONGTYPE Operation against a key holding the wrong kind of value php

I am using Laravel with Redis .When I am trying to access a key by get method then get following error "WRONGTYPE Operation against a key holding the wrong...

php-dev Solved
TR
asked 5 months ago by Trushar Narodia
0 votes
3 ans
30 views
How do I compare two DateTime objects in PHP 5.2.8?

Having a look on the PHP documentation, the following two methods of the `DateTime` object would both seem to solve my problem: - <a href="http://au....

php-dev Solved
RE
asked 5 months ago by RedBlueThing
0 votes
3 ans
30 views
Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php

This error message is being presented, any suggestions? > Allowed memory size of 33554432 bytes exhausted (tried to allocate > 43148176 bytes) in php

php-dev Solved
PA
asked 5 months ago by panidarapu
0 votes
3 ans
28 views
Best practices to test protected methods with PHPUnit

I found the discussion on [Do you test private method][1] informative. I have decided, that in some classes, I want to have protected methods, but test them....

php-dev Solved
GR
asked 5 months ago by GrGr
0 votes
3 ans
31 views
How to call a function from a string stored in a variable?

I need to be able to call a function, but the function name is stored in a variable, is this possible? e.g: ```php function foo () { //code here }...

php-dev Solved
LI
asked 5 months ago by Lizard
0 votes
2 ans
27 views
Split a comma-delimited string into an array?

I need to split my string input into an array at the commas. Is there a way to explode a comma-separated string into a flat, indexed array? Input:...

php-dev Solved
KE
asked 5 months ago by Kevin
0 votes
3 ans
23 views
How to fix Error: laravel.log could not be opened?

I'm pretty new at laravel, in fact and I'm trying to create my very first project. for some reason I keep getting this error (I haven't even started...

php-dev Solved
FR
asked 5 months ago by frankelot
0 votes
2 ans
28 views
How to set HTTP header to UTF-8 using PHP which is valid in W3C validator

I have several [PHP][1] pages echoing out various things into [HTML][2] pages with the following code. <meta http-equiv="Content-type" conte...

php-dev Solved
MA
asked 5 months ago by manycheese
0 votes
3 ans
28 views
How to remove a cookie in PHP?

When I want to remove a Cookie I try unset($_COOKIE['hello']); I see in my cookie browser from firefox that the cookie still exists. How can I...

php-dev Solved
SA
asked 5 months ago by sanders
0 votes
3 ans
27 views
How to Set Variables in a Laravel Blade Template

I'm reading the Laravel Blade [documentation][1] and I can't figure out how to assign variables inside a template for use later. I can't do `{{ $old...

php-dev Solved
DU
asked 5 months ago by duality_