Skip to content

Tag: php

Creating a table with mysql, php and ajax (with jquery)

For my new project i want the so modern approach of not needing to reload a page on every database request. 🙂 I want the script to query the database and create a table with the query information. I have tried different scripts i have found on the internet. The one below was closest to my needs. index.php get…

Return data back to dispatcher from event observer in Magento

I have an extension for product registration that dispatches an event after the registration is saved. Another extension uses that event to generate a coupon for a virtual product if it is related to the registered product. I need to get back data on the generated coupon to send to the user in an email along …

Learning how to refactor PHP code

I’m using PHP 5.2.9 at the very moment. Is there a way to refactor this code this way it’s easier to read and better organized? Answer It depends on what exactly you mean by “compress”? Since you haven’t clarified you’re getting a basic response. Removing spaces: If you are…

symfony2: how to access service from template

If I created a service is there a way to access it from twig, without creating a twig.extension? Answer You can set the service a twig global variable in config.yml, e.g And in your template.html.twig file you can invoke your service this way: See here.

sorting a column in a PHP array

I am trying to sort by a column(s) in the following data structure that I have built like this: This is a var_dump of the $entity_list data structure. How do I use asort() or ksort() on this structure? I think i should be using ksort(), as it works on a key. I have tried ksort($entity_list,’student_last…