php

Inserting only unique values into an array

I have a set of values that I'm pushing into an array in the order they occur $valsArray = array(); //I process each value from a file (code removed for simplicity) //and then add into the array $valsArray[] = $val; How do I turn this into an associative array instead where the value gets inserted (as $key of associative array)...

PHP imagettftext: bounding boxes of letters superimpose above each other

I'm writing text-images on the fly with PHPs imagettftext, which works fine so far, but I have a very strange problem. We are using a very italicized font and apparently the bounding boxes of later letters are sometimes superimposing their background over previous letters, thus cutting into them. A screenshot of the effect can be seen...

How can I combine two mysql queries into one?

I want to combine these two queries into one: mysql_query("INSERT INTO categories (name, parent) VALUES ('$name', '$parent')"); mysql_query("UPDATE categories SET child='$child' WHERE ID = $id"); Can it be done? ...

Check whether the string is a unix timestamp

I have a string and I need to find out whether it is a unix timestamp or not, how can I do that effectively? I found this thread via Google, but it doesn't come up with a very solid answer, I'm afraid. (And yes, I cribbed the question from the original poster on the aforementioned thread). ...

WordPress: add a customized Category Manager to the *PAGE* editor

In WordPress, the post editor contains a Categories panel that allows you to assign categories to posts. However, the page editor does not have a Categories panel. I'm sure this is by design, but I need a modified set of category items to be available to pages. I've found that I can add the line of code below to my theme's functions.php...

Serving files (800MB) results in an empty file

Hello, with the following code, small files are served fine, however large (see, 800MB and above) result in empty files! Would I need to do something with apache to solve this? <?php class Model_Download { function __construct($path, $file_name) { $this->full_path = $path.$file_name; } public function e...

Changing Theme code of Wordpress via Plugin

How can I changing/ adding code of the Themes with a wordpress plugin? Example: Adding before or after the comments-forms a few lines. ...

Class definition problem

Can someone tell me why I cannot write a class as follows <?php class Foo { ?> <?php function bar() { print "bar"; } } ?> I think it's the same as <?php class Foo { function bar() { print "bar"; } } ?> ...

Show last 4 table entries mysql php

I have a movie database Kind of like a blog and I want to display the last 4 created entries. I have a column in my table for timestamp called 'dateadded'. Using this code how would I only display the 4 most recent entries to table <?php //connect to database mysql_connect($mysql_hostname,$mysql_user,$mysql_password); @mysql_select_db($...

creating a data grid in javascript

Hi, I want to know if there is an API to create a datagrid like here: http://socghop.appspot.com/gsoc/program/accepted_orgs/google/gsoc2010 ...

How to join a table in symfony (Propel) and retrieve object from both table with one query

Hi, I'm trying to get an easy way to fetch data from two joined Mysql table using Propel (inside Symfony) but in one query. Let's say I do this simple thing: $comment = CommentPeer::RetrieveByPk(1); print $comment->getArticle()->getTitle(); //Assuming the Article table is joined to the Comment table Symfony will call 2 queries to ge...

change font in sharedbook api in php

I m using Sharedbook api to generate a memory book, although it's working perfect, but font of the memory book is unchangeable ...means i can't change the font family of that book. I tried to change the font then it display error. please suggest me how to change Font of that memory book.. Thank is advance ...

Where download php_memcache.dll ?

Hello, I'm trying to download from http://pecl4win.php.net/ext.php/php_memcache.dll but "The pecl4win build box is temporarily out of service. We're preparing a new build system." Thank you. PHP version is 5.3 ...

Embedding a YouTube Video Based on a PHP Variable

I have a website that I am creating for a class project. The website shows information about bands (which is stored in a mysql database). I am trying to spruce up the site a bit, and I would like to embed a YouTube video based on the band's name. Say, for instance, I have "Led Zeppelin" stored in my database. How can I take a PHP variabl...

PHP HTML Embed PHP Tags within a .HTML Document Is This Possible??

Embedding HTML within .PHP files is one of the primary functionalities of PHP, but is it possible to do it the other way round? I mean, embedding PHP tags, , within a .HTML document?? Is this sort of coding possible? Any suggestions welcome. ...

tools for quick php development

I'm a PHP developer looking to speed up my production time, and add a new ability to my CV. I'm after a package that provides the basic CMS features that I can build on for a wide range of purposes. I've heard of PHPcake, Drupal ect but I don't know enough about these to make an informed decision. What alternatives are there? Are they O...

How do I sort a directory by time, and display the last four image files matching a pattern with php?

I have a directory that will be getting updated frequently, I want to display the last four images files uploaded, which match a certain pattern, on my php page. Is this possible without having to perform a sort on every single image within the directory? Many thanks! ...

jQuery: split and hide html data

Hi guys! I need to split somehow some html data (a text with html tags) into two parts and hide the second one with a show/hide link. The thing is all texts are being stored in the database with html tags. Some of those texts are short, but some are really long. We don't want't to show long ones, so one of the options is to show a teas...

Breaking a PHP code with Javascript confirm dialog?

I have PHP scrip that goes like this: if ($cost_frm < $cost){ echo "<script type='text/javascript'> var r = confirm('Input cost is lower than original. Sure?')); If (r==true){ } else{ *** BREAK PHP SCRIPT *** } </script>"; } And I'd like to...

preg_replace: unknown modifier

Let assume that $body is equal to something that does not interest me <!-- start --> some html code <!-- end --> something that does not interest me If I use $body=preg_replace("(.*)<!-- start -->(.*)<!-- end -->(.*)","$2",$body); I obtain: Warning: preg_replace() [function.preg-replace]: Unknown modifier '<' How have I t...