Skip to content
Advertisement

PHP PDO output to specific Json Format

I have been trying to get a query output formatted in a specific way but I am surely doing something wrong. Could anyone that knows what I am doing wrong give me a hand? Thanks a lot. I have the following db call: If I run this query in the db (mysql) I get this: When I make a call

Laravel 9 Array Filter

I have this array cart_items and works fine when mapped for database storage as in the code. I need to filter the array using Arr:where(), where the product shop_id is a specific value. I tried using an if function but the code just looped returing true where the shop_id was present. I need to filter the array where the product

How do I filter with dropdown list? PHP and SQL

We are trying to filter based on the tags or the dropdown menu, we are trying to create a blog website that has tags and those tags can be used to filter the posted content on the homepage Tags dropdown menu:. Here should be the content in the page: Here should be the content in the page: Answer Set tags

regex to isolate javascript using preg_replace_callback

My [php executed] regex is terrible and I’m struggling with trying to isolate javascript scripting within HTML blocks. I have the following regex that works partially, but it’s run into a problem if there’s the word “on” in the text (as opposed to in a < tag >). I think the issue is that the bon…. part needs to be

How to send custom emoji by Telegram bot?

I want to send premium emojis by Telegram bot (I have a premium account and created a bot with it), but when I try to send it (I send emojis to the premium account), unfortunately, the emoji is sent normally. my code: Message should be like this: Answer This feature will be activated in the future. https://telegram.org/faq_premium#q-can-i-buy-a-premium-subscription-for-my-bots

How to get intersection between two strings in PHP

A problem description: I have two strings and I need to find the length of intersection of them. Let’s assume the both strings are Latin-ASCII and lower case. These are expected results: My try to solve the problem: I’ve tried to compare the strings using array_intersect() function this way: But this way of comparing two strings is inappropriate because it

Cannot terminate or close a PDO connection MySQL

The page seems to continue loading indefinitely event when the script reaches the end. How can I terminate the connection after breaking out of the PHP loop? I have set the $pdo and $usearch variables to null and reviewed other questions. Answer I moved to MySQLi:

Pass variable to view via controller in Laravel

I need help with passing the variable I have initialized using __construct() to view in Laravel. Here is my controller code I get an error undefined variable profileInfo Answer When using compact() the parameters used must be defined as variables: In this case compact() will create an array like this:

PHP Union Types with default value

I wanted to implement methods with union-type dependencies for the argument like so: but it’s triggering an error I looked through the documentation but there is no mention of this. Thanks in advance Answer You can add new type for other type hint:

Advertisement