LMSouq

Knowledge Base

Browse Moodle Solutions

2108 solutions found

Page 21 of 106
0 votes
1 ans
3 views
Laravel Eloquent Query: Using WHERE with OR AND OR?

How do I say `WHERE (a = 1 OR b =1 ) AND (c = 1 OR d = 1)` For more complicated queries am I supposed to use raw SQL?

database Solved
FA
asked 1 month ago by Farzher
0 votes
1 ans
3 views
urlencode vs rawurlencode?

If I want to create a URL using a variable I have two choices to encode the string. `urlencode()` and `rawurlencode()`. What exactly are the differences and...

general-dev Solved
GA
asked 1 month ago by Gary Willoughby
0 votes
1 ans
3 views
PHP code is not being executed, but the code shows in the browser source code

I'm trying to execute some PHP code on a project (using Dreamweaver) but the code isn't being run. When I check the source code, the PHP code appears...

php-dev Solved
GU
asked 1 month ago by Gui
0 votes
1 ans
3 views
Using str_replace so that it only acts on the first match?

I want a version of `str_replace()` that only replaces the first occurrence of `$search` in the `$subject`. Is there an easy solution to this, or do I need a ha...

general-dev Solved
NI
asked 1 month ago by Nick Heiner
0 votes
1 ans
3 views
How to remove non-alphanumeric characters?

I need to remove all characters from a string which aren't in `a-z A-Z 0-9` set or are not spaces. Does anyone have a function to do this?

general-dev Solved
ZU
asked 1 month ago by zuk1
0 votes
1 ans
3 views
How can I get the current time in milliseconds in PHP?

`time()` is in seconds. Is there one in milliseconds?

php-dev Solved
CO
asked 1 month ago by COMer
0 votes
1 ans
3 views
Website screenshots

Is there any way of taking a screenshot of a website in PHP, then saving it to a file?

server-admin Solved
TO
asked 1 month ago by Tom
0 votes
1 ans
3 views
How can I write to the console in PHP?

Is it possible write a string or log into the console? ## What I mean Just like in JSP, if we print something like `system.out.println("some")`,...

php-dev Solved
LA
asked 1 month ago by Labeeb Panampullan
0 votes
1 ans
3 views
Replace keys in an array based on another lookup/mapping array

I have an associative array in the form `key => value` where key is a numerical value, however it is not a sequential numerical value. The key is actually an...

php-dev Solved
TH
asked 1 month ago by Thomas Owens
0 votes
1 ans
3 views
Difference between array_map, array_walk and array_filter

What exactly is the difference between `array_map`, `array_walk` and `array_filter`. What I could see from documentation is that you could pass a callback funct...

php-dev Solved
WE
asked 1 month ago by Web Logic
0 votes
1 ans
3 views
Can PHP cURL retrieve response headers AND body in a single request?

Is there any way to get both headers and body for a cURL request using PHP? I found that this option: curl_setopt($ch, CURLOPT_HEADER, true); is going...

php-dev Solved
GR
asked 1 month ago by gremo
0 votes
1 ans
3 views
Why would one omit the close tag?

I keep reading it is poor practice to use the PHP close tag `?>` at the end of the file. The header problem seems irrelevant in the following context (and th...

general-dev Solved
JO
asked 1 month ago by johnlemon
0 votes
1 ans
3 views
How can I get the last 7 characters of a PHP string?

How would I go about grabbing the last 7 characters of the string below? For example: $dynamicstring = "2490slkj409slk5409els"; $newstr...

php-dev Solved
DA
asked 1 month ago by Dave
0 votes
1 ans
3 views
How do I check if a directory exists? "is_dir", "file_exists" or both?

I want to create a directory if it does not exist already. Is using the `is_dir` function enough for that purpose? if ( !is_dir( $dir ) ) { m...

general-dev Solved
PE
asked 1 month ago by Peter
0 votes
1 ans
3 views
Laravel Checking If a Record Exists

I am new to Laravel. How do I find if a record exists? <!-- language: lang-php --> $user = User::where('email', '=', Input...

php-dev Solved
BE
asked 1 month ago by Ben
0 votes
1 ans
3 views
Get the Last Inserted Id Using Laravel Eloquent

I'm currently using the below code to insert data in a table: <!-- language: php --> <?php public function saveDetailsCompany(...

php-dev Solved
SO
asked 1 month ago by SoldierCorp
0 votes
1 ans
3 views
Call a REST API in PHP

Our client had given me a REST API to which I need to make a PHP call. But as a matter of fact, the documentation given with the API is very limited, so I don&#...

php-dev Solved
MI
asked 1 month ago by Michiel
0 votes
1 ans
3 views
Default value in Doctrine

How do I set a default value in Doctrine 2?

general-dev Solved
JI
asked 1 month ago by Jiew Meng
0 votes
1 ans
3 views
How to get body of a JSON POST in PHP?

I submit as POST to a PHP page the following data: ```json {a:1} ``` In my PHP code, what do I have to do to extract that value? ```php var_dump($_PO...

php-dev Solved
IT
asked 1 month ago by Itay Moav -Malimovka
0 votes
1 ans
3 views
Best way to do multiple constructors in PHP

You can't put two __construct functions with unique argument signatures in a PHP class. I'd like to do this: class Student { protec...

php-dev Solved
JA
asked 1 month ago by Jannie Theunissen