I’m building a website and I want to monitor a folder for changes, and when those changes happen I want to start my PHP script, which runs an SQL query to builds my table. Here is the script: This is largely from nixda, so credit goes to them Answer To synchronously execute console applications or batch…
Tag: php
Index an array using a callback function to get the key
Is there a built-in PHP function that does the following? I think I’ve reviewed all array_*() functions, but am surprised that this use case is not covered by any native function. Answer There’s no built-in function that does this in one step. But you can use array_map() to get the new keys from t…
Ajax JSON.parse JSONarray
I am trying populate a form from a mysqli database when an option is selected from a drop down. I am trying to do this with an ajax ‘get’ call to a PHP page. The PHP page does the SQL query and returns the results, then I do a json_encode of the data. This puts the JSON into an array.
Button not showing selected on tab load from jquery
When I load the page normally, it will display corrected. However when attempting to load the tab through the url IE: page.php#tab2, the tab navigation will not select the tab I am currently on and will instead load the default tab “tab1” jquery: html: What it’s doing… https://i.stack.…
Sorting an associative array with a string in PHP
I’m working on a php issue with an associative array and attempting to sort it. What I have looks something like this: I want to sort it so it looks like this: I’ve thought about exploding along the | and then taking the 0.0.0.111 and comparing it to everything else. What I tried look like this: I…
Laravel Relationship Getting All Children
I have a query which returns a table. I would like to also return a list of styles which relate to it from another table. I have tried many things but I can’t find one which works. Any advice? Query: YarnOrderLines: YarnOrderLineStyles (table with relating styles in I would like to pull in) Answer You&#…
Use explode on array?
What’s the easiest way to turn the array into Is there something built-in with laravel/collections that I can use? I know I can make a foreach loop and use explode and populate a new array, but I’m wondering if there is a built-in function in PHP or a laravel collections method I can use. Answer I…
css in the menu does not work because the id is pushed into the wrong container
i want to use this code in wordpress. The first code shows the working code. The second code shows how it is displayed in WordPress when I use this position <?php wp_nav_menu (array (‘menu_id’ => ‘main-nav’,)); ?> it is packed in the ul but it has to be represented as above ar…
PhpStorm Expression Expected Using PHP Short Echo Tags Inside HTML Attributes
I found something similar to this while doing a code review, and I don’t see what is wrong with the code (shown as a syntax error by PhpStorm). The problem is using PHP short echo tags in an HTML attribute. PhpStorm doesn’t seem to have a problem with the usage in the label’s for attribute, …
PHP odbc_exec not returning all rows
This simple query when run in DBExplorer (a DB tool for executing raw SQL queries), returns 5 rows (contents of an invoice). Everything is setup in such a way that an invoice may contain multiple goods of the same ID (but with different prices and procurement prices, printing names – e.g. bucket-white, …