So currently I have this code: And i’m getting this json response: But I would like to get rid of id and weather from the json. Decoding and then encoding again seems like a bad way to do it. Can I access needed values before serializing them to json? I would like to get something like this: Sorry if it…
Tag: php
CRUD table with Ajax + Datatables does not work
I’m creating a CRUD table with Ajax + Datatables, but for any reason, my code does not work. I can get my json response with my data from my database, but I don’t know why, it can’t be printed on my table. Im using 2 files: 1.- main.php: 2.- crud.php: Just to clarify some things … I…
How to remove specific element from array in php
I have the following array I want to remove 60b6a8a38cf91900695dd46b from the multiple_assignee array. I have tried with the following code: But it is not removing that element. The intention is I don’t want to repeat the 60b6a8a38cf91900695dd46b assignee in the multiple assignee array. I have also trie…
Laravel, how to display Values in DB with just given IDs?
im trying to get 5 data from DB with their ID ? HTML Route Controller – im Trying to get Just 1 ID and its not Working I want to show 5 Offers from Offers Table, with given 5 ID in HTML Form ? How can i do this in Laravel ? Answer You never execute your query… where() is
How to catch a fatal error both in PHP 7 and 8?
I have a PHP 7 script, that basically does this: To be clear: if the class I am looking for is “Main” and can’t be found, I must display the text, else it’s supposed to throw the exception anyway. It works well with PHP 7, but PHP 8 does not catch the error. Instead, it shows: How am I…
After changing name of a file it goes parent directory
I’m writing a PHP code that takes names from input.txt file and with those names it changes the names of files in the image folder. My code is: It works but at last, files in the ‘image’ folder go C:wamp64wwwReplace image names with input directory. (Parent directory) Any idea why this happe…
How to select all js files which is located in a folder or under a subfolder
I want to import my script files dynamicly. I’ve coded a simple think but it is not working how I expected. I want to select all js files which is located in a folder and its subfolders. In this code, example.js is not loaded. my folder Answer You can adjust your pattern this way. Note that the GLOB_BRA…
Why cookies are added rather than changed?
I am developing a site where each user should have their own id. When I went into the console, I saw that the id was duplicated instead of being one. Is this normal and should it be? Answer Cookies, by default, use the path of the page that they are set for. You should explicitly set the path to /
Restore content file_get_content() function
I gave an image as a parameter to the file_get_content() function and received it as the output of a string. Now I want to do the opposite of this operation. What should I do? Answer You can write it back to an image file using file_put_contents Example: If you then look into your folder “images/”…
How to pass data to symfony form class without using static
I’ve got form class and i have to pass args to it but i can’t do that because i am using createNamed function which requires me to use namespace string. code: I can’t pass this data into entity, because it is an arguments for creating the form fields rather than data model. Answer Have you t…