So I have a function that currently has a foreach and it works amazing, but I’m being forced to change it to a while loop: PLEASE NOTE: The developers at my company don’t want to use the foreach and they think that a while loop would be more efficient, but I’m not understanding how that woul…
Tag: php
How to get class from a constant array?
I have about twenty different classes that are segregated in an assoc array similar to this: But now I want to do the array constant. I can make it using const VAL = array(); just fine. The problem lies in making new objects using those classes fails with Parse error: syntax error, unexpected ‘[‘,…
HLS/m3u8 stream checker for a LIVE badge/image
Hey everybody how are you doing. I have a small but for me a headache question. In short. I want to show a ”LIVE” badge/image if a HLS/m3u8 stream is active. If somebody know’s how to achieve this, i would really appreciate it. Tried to google it but im clueless when it comes to implementing…
Laravel 8.53 – Routing doesnt work on any of pages
Solution The solution was found thanks to @Gert B. Simply add to your Laravel application any virtual host (I added for mine) laravel1.test How to add Virtual host: Go to C:WindowsSystem32driversetchosts add line: 127.0.0.1 laravel1.test (or your virtual host name) And add this to your vhosts(in case of using…
Laravel find rows by nested relationship column
I have 2 tables reserves and chats, chats belongTo reserves and I want to get all chats where chat.reserve.user_id = Auth::id(). How can I do that in laravel. Answer I don`t know your models name (need more code in question), but try use where ‘reserves’ your relationship and have field user_id. M…
Determine name of table referenced by a foreign key from another table using PHP?
Just learning mysql and php and having to create a test project for my exam. How do I determine the name of a table (target) a foreign key from another table (source) references, and how would I go about that with PHP? I have been googling this as well as browsing SO for it for hours, but have not found
How to display thumbnail image from custom post type in another post type?
I have two custom post types “book” and “author”. I want to display author’s thumbnail in book’s post card. I think here should be loop inside the loop, but don’t understand how to implement it. Answer If you use ACF with Post Object field type, change your <–…
d3.js – PHP Array format
I need to create a d3.js chart using PHP formatted array for JSON. The format is like: The array code and format that I currently have is below. The format of the array clearly needs to be changed, but I’m not sure how to do that to suite the above format. Answer The best approach may be to create your
php can not get array value from an array
I have an array: And I would like to get the first value in the array: I have tried each of the following: array_values($_array)[0]; $data[0]; array_keys($data)[0]; But none of them work, and I instead get an empty string. I need to get the first element or key of the array. Answer you can use array_key_first…
PayUbiz success url not called if using 3rd party apps
I have integrated PayUbiz payment gateway in one of my clients website. It works fine if customer pays using Cards or Net Banking, but when any customer tries to pay the amount using 3rd party apps eg: Google Pay, I am unable to capture the payment success callback from PayU (The payment is made successfully …