php

convert an 1D array to multidimensional array in PHP

Hello, I have this array: Array ( [1] => animal [1-1] => turtle [1-1-1] => sea turtle [1-1-2] => box turtle [1-1-3] => green turtle [1-1-3-1] => green turtle with brown tail ) and I want some how to convert it into: Array ( [1-title] => animal [1-sons] => array( [1-1-title] => turtle ...

Runkit : does not work on a linux server

Hi, I have a problem with PECL::Runkit with this little example index.php contain <?php runkit_import('a.php'); runkit_import('b.php'); Doublon::get(); a.php et b.php each contain the same code class Doublon { static function get() { echo "class " . __FILE__; } } On my PC (Windows XP, Wampserver 2, php 5.2.9-2, runkit DLL bundled...

PHP/MYSQL query help with grouping results

I have a MYSQL table with 3 fields: CODE, DATE, COUNT. CODE is the ID of the client DATE is the date the entry was added COUNT is the number of credits used by that client on that date I need to be able to know how many credits each client has used on a per month basis. So I need to group the results by client and by year/month. Basic...

Problem calling a js function from php

I am using my php to call a js function like this: <?php $chk=1; if($chk==1) { echo '<script>testing();</script>'; } ?> and my js looks like: function testing() { document.getElementById("mainbody").innerHTML="This is my first JavaScript!"; } The js is an external js file. My html looks like: <html> <head> <script src="qo...

Flickr group pool photos - how to download all group photos

Our family has created a Flickr group in honor of a recently deceased relative. We are planning to show the group pool slideshow at her memorial service. The flickr slideshow functionality is great, but it does not auto loop. Plus randomizing photos within a large group pool does not seem to be easy. I'd like to just download all the g...

PHP Weight Algorithm

I'm wondering if this is a sufficient algorithm for finding the best value with a weighted system. Is there anything I could add to make it better? Edit: in this example I would like the probability of $object->get() returning test4 to be 4 times greater than the probability of it returning test1 (thanks acrosman) Thanks class weight...

new version for the classes I've use in my application

Hi there 2 months ago I was writing a web-application which use some classes to draw some charts. I've modified little those classes in order to fit with my needs. Now I wish to use a new(and official) version of that class, but also to have my modifications available. The problem is that I don't remember exactly all the modification ...

How do I add an array as an Object Property to a class declared within a PHP extension?

I want my PHP extension to declare a class equivalent to the following PHP: class MyClass { public $MyMemberArray; __construct() { $this->MyMemberArray = array(); } } I'm following the examples in "Advanced PHP Programming" and "Extending and Embedding PHP" and I'm able to declare a class that has integer prop...

PHP quirks and pitfalls

I've realized that, although most of my experience consists in writing PHP applications, I find myself making "beginner mistakes" from time to time. This because PHP is a language that has grown very organically and as such has some idiosyncrasies, quirks and pitfalls that I don't know about. I'd like this question to be a wiki for all ...

php javascript url encoding

I have a html text. I had encoded it in php using urlencode function. I want to decode that text in the javascript. when i use unescape function in javascript it replaces all the special characters back but sapce is replaced by '+'. how can i do it correctly so that space is replaced as space itself??? ...

Still stuck on my php calling javascript problem. Please help in this

Still stuck on my PHP calling a JS script problem On the click of a button this Javascript is called: var xmlhttp; function register() { xmlhttp=GetXmlHttpObject(); alert("pass"); if(xmlhttp==null) { alert("Your browser does not support AJAX!"); return; } var url="register.php"; url=url+"?id="+uniqueid+"&name="+name+"&pa...

PHP : How can I read an .XLS file's contents without saving it to the server?

I am working on a database program using PHP to keep track of the products we manage at my workplace. For this project, I need to be able to select an .XLS file which contains new product data. New data consists of the following fields: Type CHAR(3), Line CHAR(2), Number INT, Measure INT, Comments VARCHAR(255), Variation...

MySQL joins, how to output relation "the proper way"

Hello, First of all, excuse my poor topic title. I simply have no idea how to formulate this question or what to Google after, so don't shoot me if this is something easy answerable. Assume I have the following tables: [AUTHORS] id, name [NEWS] id, item, author_id If I wanted to display a news item and output the corresponding autho...

Converting Unicode code points to UTF-8

Currently I have something like this \u4eac\u90fd and I want to convert it to UTF-8 so I can insert it into a database. ...

Help with getting values through regex (php)

So yea, I suck with regular expressions. Needs to be done with php. Thanks. I need to be able to pull out "xx" (will always be 2 lowercase alphabetic chars) and "a12" (can be anything but will always be .php). String: http://foo.bar.com/some_directory/xx/a12.php?whatever=youwant ...

CodeIgniter: Directing to functions with a URL segment

Hello All, I'm working on a survey system for my company and I have it setup in the system so that there are two ways to take the survey. 1) New Survey Taker no prior information 2)Survey was already sent out and a session was created. In case one I would like my URL to look like: mydomain.com/SurveySystem/index.php/survey/$surv...

Why Do I Get This Segmentation Fault In This PHP Command Line Script?

It's just a quick script to a message to what I call a 'mental log file'. Just to keep track of my thoughts when I drift off and get myself back to work. Anyway, it works alright most of the time, but every so often I get a segmentation fault. Heard of them in C, but never had them before in PHP. Here's the script: #!/usr/bin/php <?php...

htaccess rule to forward /login/ and /login to same page?

I have the following rule in my current .htaccess file to redirect /videos/login/ requests to /videos/login.php RewriteRule login/ /videos/login.php This works fine if I am access login page using http://mysite.com/videos/login/ but when I am trying to access the same page using http://mysite.com/videos/login (without ending slash) th...

How do you sanitize your data?

This is the function i currently use(from a php book i bought): function escape($data) { return mysql_real_escape_string(trim($data), $this->linkid); } But I feel like it could be safer. for example, maybe use htmlspecialchars. It always makes me paranoid. I've read that mysql_real_escape_string is bad and never to use it, but then ...

How to parse XML in order to extract data from MySQL Database.

Hello Here is a simple form to send to admin_xml.php <form name="review" action="admin_xml.php" method="post"> <textarea name="xml" cols="40" rows="10"></textarea> <input class="submit" type="submit" value="Submit Request"> </form> Here is the XML which I want to enter into the form to extract Data from MySQL Database. <?xml ver...