php

How does gettext handle dynamic content?

In php (or maybe gettext in general), what does gettext do when it sees a variable to dynamic content? I have 2 cases in mind. 1) Let's say I have <?=$user1?> poked John <?=$user2?>. Maybe in some language the order of the words is different. How does gettext handle that? (no, I'm not building facebook, that was just an example) 2) ...

How do I concatenate a string in a PHP Array Element?

I am customizing wordpress blog and I have a need to make custom sidebar widgets. My PHP is rusty at best. What I am trying to do is concatenate a php variable into a string being set as an array element. here is the code I am using, it doesn't seem to work. All it does is print the stylesheet directory at the top of every page: if ...

str_ireplace() not accutally removing the 'needles'

I'm using str_ireplace() to remove instances of strings in an array, and I'm returning the number of counted occurances, but it's not actually performing the replace. //replace occurances of insert, update, delete, select $dmlArray = array('select', 'update', 'delete', 'insert'); str_ireplace($dmlArray,'-- replaced DML -- ',$clean['com...

Looking for a PHP mailing list App (not for newsletters)

I am not sure if I'm calling this correctly by the right name, what I would like to find (if it exists) is a group mailing list app (like mailman) but in php. Here is what I expect it to do: Allow for users to email [email protected] with subject like TEAM123 - Deadline is 11/30/2011 (or maybe just [email protected]) and this app...

Generate random string, check it against database, then use it.

This is an issue which keeps coming up for me when using random strings. This is basically the process. Generate random string Check if it already exists in the database If it doesn't use it, else generate another one So how would I do this using PHP? ...

How to suppress/remove PHP session cookie

I need to suppress an already set session cookie header, but I cannot find any way to do this. Why? I need to make an image, sent by a PHP script, cacheable by the end user; this image is used to track if a newsletter has been read by the receiver, so if the image is requested I know the newsletter has been read. I only need to know whe...

Should one use PHP to print all of a page's HTML?

Hi So I've always developed PHP pages like this: <?php goes at the top, ?> goes at the bottom, and all the HTML gets either print()ed or echo()ed out. Is that slower than having non-dynamic html outputted outside of <?php ?> tags? I can't seem to find any info about this. Thanks! --Mala UPDATE: the consesus seems to be on doing it my ...

My php can't find 'normalizer_normalize()' function, why?

How come I can't use normalizer function? I am using it exactly as I should, ie: $var = normalizer_normalize($str); I get php error: no such function! Here is the code: $headline= mysql_real_escape_string($_POST['headline']); $ad_id_string=normalizer_normalize($headline); Thanks ...

RGB to HSV in PHP

In PHP, what is the most straightforward way to convert a RGB triplet to HSV values? ...

How can I turn an open source game into an open source community?

Related question: How do I attract developers to an Open Source project? Coding an open source Browser-Based-Game I code the game/site ninjawars.net. Recently we (me and my friend who mainly admins the server these days) open sourced the code (and creative commons share-alike'ed it). I really love working collaboratively on code, and...

preg_match returning weird results

I am searching a string for urls...and my preg_match is giving me an incorrect amount of matches for my demo string. String: Hey there, come check out my site at www.example.com Function: preg_match("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", $string, $links); echo count($links); The result comes out as 3. Can anybody help...

How do I use conditionals to differentiate between Page and Subpage in WordPress?

I have been using conditionals to be able to tell if I'm on a page or a subpage of that page, but I cannot for the life of me get the code to do one thing if I'm on the master page,and another thing if I'm on a subpage of that master page. This is what I have been using so far: if ( is_page('3') || $post->post_parent == '3' ){} Does a...

Mysqli query with a SET variable statment (ie multiple queries)

I want to set a variable to use in a mysqli query. This doesn't quite work. Prior to mysqli I used to set query calls. I played around with db->multi_query($sql) with no luck. Anyone out there have an idea how to make this work including a set statement? $sql = 'SET @rownum := 0;'; $sql .= 'SELECT @rownum :=@rownum + 1 AS Rank, User...

Get Youtube Video ID from html code with PHP

I want to get all only youtube video ID from html code look the (or multiple) object/embed code for youtube video // html from database <p>loremm ipsum dolor sit amet enot <a href="link" attribute=""blah blah blah">anchor link</a> </p> <object width="425" height="344"> <param name="movie" value="http://www.you...

How to parse returned php data

I am accessing an external PHP server feed (not a real link): $raw = file_get_contents('http://www.domain.com/getResults.php'); that returns data in the following context: <pre>Array ( [RequestResult] => Array ( [Response] => Success [Value] => 100 [Name] => Abracadabra ...

Creating functions without parentheses in PHP like 'echo'

Hey all, I was wondering if there is any nice way of writing functions in PHP so that they don't require ( ) around the parameters. Example: function sayThis($str) { echo $str; } sayThis "hi!!"; Thanks, Matt Mueller ...

Default associative array value in PHP

Hey all, I'm just wondering if its possible to have something like this: $image = array( "default" => "test.jpg", "width" => 400, "height" => 500 ); Then you could call: echo $image // test.jpg echo $image['width'] // 400 Thanks, Matt Mueller ...

How to strip this part of my string ?

$string = "Hot_Chicks_call_me_at_123456789"; How can I strip away so that I only have the numberst after the last letter in the string above? Example, I need a way to check a string and remove everything in front of (the last UNDERSCORE FOLLOWED by the NUMBERS) Any smart solutions for this? Thanks BTW, it's PHP! ...

Combining javascript / jQuery and PHP

I'm using Uploadify to upload an image. Now I need to get the correct upload path. I have the following code / script: <?php $uploadifyPath = get_bloginfo('url') . '/wp-content/plugins/uploadify/'; $galleryPath = "'".getGalleryURL('1620')."'"; // <--- 1620 is inputed by me. ?> <input id="galleryID" type="hidden" value="...

PHP4 problems with include() within a file created by fwrite()

I have a file called generator.php that uses fwrite() to create a result.php on the server (Apache, PHP4). One of the lines in result.php is a PHP include() statement. So, in generator.php: if (!is_file($fname)){ $resultfile = fopen($current_path . "/" . $fname, "w+"); } fwrite($resultfile, '<?php include($_SERVER["DOCUMENT_ROOT"]...