php

Merging multiple associative arrays in PHP

I'm not quite sure how to do this. Let's say I have 2 associative arrays $arr1 = array('a' => "1", 'b' => "2", 'c' => "3"); $arr2 = array('a' => "9", 'b' => "8", 'c' => "7"); How could I possibly produce an "add-up" array as below $arr1 = array( array('a', "1", "9"), array('b', "2", "8"), array('c', "3", "7") ); I'm not sure...

json_decode on retrieved json string from mysql does not work

I have a string json that gives the following var dump: "[[{"TransactionID":"00416","OrderID":"000926","TransactionOrderItemID":"001123","LastUpdate":"2009-10-28 13:03:31","CustomerID":"184","Company_name":"Test123","Invoiced":"0","SubItemsCount":"2","ProductID":"1","ProductTypesID":"1","ProductTypeName":"Phone","ProductName":"Phone Lin...

How to index an array?

Hello! I have a multi dimensional array, like this: array('name' => array('title'=>'Title','date'=>'Created')) I store it as JSON 'array', and when I decode it, I want to reach every item by its number, so I want an indexed array. How could I solve this in PHP? Tim ...

How to get OpenID user Profile info?

After logging into SO, my nickname shows up at the top. When I set up openid on my site, I do not get any profile information. I tried implementing OpenID using openid-selector and Zend Framework The response parameters I get: openid.assoc_handle B2Jgsdf7jkDsdfUwWBGMHUshLmavymH... openid.claimed_id https://me.yahoo.com/MyYahooId#50...

Why is Magento so slow?

Is Magento usually so terrible slow? This is my first experience with it and the admin panel simply takes ages to load and save changes. It is a default installation with the test data. The server it is hosted on serves other non-Magento sites super fast. What is it about the PHP code that Magento uses that makes it so slow, and what ...

Counting blanks when merging assoctiative arrays

I'm trying to merge these 2 arrays $arr1 = array('a' => "1", 'b' => "2", 'c' => "3"); $arr2 = array('a' => "9", 'b' => "8", 'd' => "7"); into an array that looks like this $arr1 = array( 'a' => array("1", "9"), 'b' => array("2", "8"), 'c' => array("3", ""), 'd' => array("", "7") ); The tricky part is the blanks. I...

Errors on server! Need another set of eyes over simple php mysqli.

Hello, i have the following php code selecting user details from a mysql db $mysql = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database'); $stmt = $mysql->prepare('SELECT personalinfo.userid, personalinfo.firstname, personalinfo.lastname FROM personalinfo INNER JOIN applications O...

Separate multi dimensional array

Hello! I have a multi dimensional array in PHP. $f = array('one' => array(*doesntmatter*), two => array()); When I want to use it, I only want one of the arrays. (one or two or three etc) So I want to slice it into (in this case) two seperate arrays, like this: $one = array(**); $two = array(**); Can I solve this with a default fu...

php include virtual path

In my live site I have php include() and require() that have full path such as: /www/mysite.com/webapps/mmh/head.php or /www/mysite.com/webapps/ROOT/zip/BoundaryWizard.php Now, I want to do some local development on my windows machine (Xampp), so obviously none of those path work. Is there a way to tweak the apache or php settings to d...

Facebook Connect Examples - Connect.registerUsers and login/logout processes

I'm looking for example PHP code (preferably using the FB PHP library) that does the following: Let my website connect to my FB account when i log into FB connect. Store my facebook credentials (email hash and FBID?) locally Log me out of Facebook connect when I log out of my website Automatically log me back into FB connect without th...

How to calculate time passed with PHP or Zend_Date?

I'm trying to create a view helper that will display the number of minutes, hours, or days that have passed since...right now. I'm not really sure how to do it. It looks like the date comparison is working, but I don't know how to get the number. Here's what I have so far: <?php class Zend_View_Helper_RecentDate { public function r...

Combine sql rows with same id, sum and update the total

Hello, I am attempting to write a php script to compare rows from the database and then adds the quantities it the product id matches. Based on cusotmer_id Example: mydb.cart id, customer_id, cart_id, product_id, qty, price 1, 0001000, 4545453, 20, 10, 12.99 2, 0001000, 7473432, 20, 2, 12.99 Result 3, 0001000, 7473432, 20, 12, 25.9...

Use Zlib library to compress large include files experience?

I'm interesting in experience of others developers with Zlib, and compressing large files, and how it will depends on application processes, is that going to make application slower, or not, or will decrease any other application performance. If there is any other better solution shoot. ...

Where do I download the PHP SOAP Extension for Windows?

What is a good on-line source for downloading php_soap.dll? ...

Long (5 second) DOMContentLoaded wait when opening PHP file

Hi all, Thanks in advance for your help with this. I've got a very simple PHP file that returns HTML code for an image based on some passed parameters. The code works fine, and the image shows up quickly. However, the page itself doesn't finish loading for a good 5 seconds, which is interfering with some AJAX calls I'm trying to do. Fir...

Problem in DATE AND TIME

I am using date() function it getting the date and time as per my given format but the time its showing me is 4 hours forward than my current local machine time: This is my code echo date("Y-m-d h:i:s", time()); Its showing me : 2009-10-28 08:47:42 Where as it should Disply : 2009-10-28 04:47:42 Any Idea whats wrong with...

Using PHP variables in Javascript include files for view in MVC

Suppose I am using an MVC framework, and my views require Javascript files located in a file external to the view. My javascript located in the external file depends, however, upon a few PHP variables in my view. If I were to include the Javascript in a tag inside my HTML view, I could simply inject the PHP variables into the Javascript...

Using implode to group information from acquired in a whileloop (problem solved)

Solved the problem thanks to all of your tips. Thanks a lot for all the answers. d(^_^d) I am having the following problem. I have the numbers 1/2/3/4/5/6 and I want to separate them into two groups 1/3/5 and 2/4/6. The selection must take place based on the position. This part works ok. The problem comes when I want to group them aga...

session error php

PHP NEWB. Can't figure out why I am getting this error via line 5. Any help would be greatly appreciated. <?php session_start(); //check to see if the user has logged in with a valid password if ($_SESSION['authuser'] !=1 { echo "Sorry brah, but you don't have permission to view this page, you jerk!"; exit(); } ?> <html...

Question about Security in a live search field

This is an odd question. I have a friend who is working on an application. There is a table with 4 fields that holds a word and a definition among some other things. On a website there is a textbox in which a user can enter a string and the database is queried and looks for similar content while the string is being entered in the box. (A...