Skip to content

Tag: php

How can I add a parameter to a callback function like in JavaScript?

I wanted to make a small function that let’s me connect to the database, do something in a callback function and then automatically close the connection like so: Usage would be like this: Is it possible to achieve this somehow? Because my mysqli_conn doesn’t seem to work. How to do it? Answer Supp…

Get dependencies Ids Algorithm

I have this problem and I came out with a solution but what is the best way to solve this problem ? Thank you in advance. Given an array of strings and an array of tasks you need to return a sorted array with tasks and dependencies tasks ids. Example: Expected output: So far this is the solution I built,

Using an array as request headers in PHP

I’m trying to send a GET request to an API using PHP stream_context_create and file_get_contents. I need to add API keys to the headers of my request, I’m storing these in an array so I easily edit them later and use them in multiple functions. What is a good way to include these arrays as headers…

Can I use the same table to represent different Entities in Symfony?

I am migrating an old PHP project to Symfony. I am trying to create the entities based on the existing database schema which I can not change. I am facing a problem : There is a table that would represent two different entities. Basically, there is a boolean (a tinyint(1)), if the boolean is false, then the r…

Twilio Conversation Fatal error when trying to send message?

I am trying to do a group conversation following the twilio samples online. I have the conversation and the people are connected (I think) but when I go send a message I get the following error: Does anyone have any working samples of a working conversation in PHP? If you want I can post my full code (minus t…

undefined index when page is loaded

I’m having a issue where a variable is becoming undefined when the page is loaded individually… So. My front page has a address form where when the address is filled out and you click “Get your offer” it’ll take you to another page where the address is carried over using $_POST[&…