What's the fastest way to populate an array with the numbers 1-100 in PHP? I want to avoid doing something like this:
$numbers = '';
for($var i = 0; i <= 100; $i++) {
$numbers = $i . ',';
}
$numberArray = $numbers.split(',');
It seems long and tedious, is there a faster way?
...
I would like to run a local PHP (5.3) website on Mac OS X 10.6. I have PHP configured properly and can access a website using http://mymac.local/~me/index.html. I have this folder structure:
~me/Sites/index.html which points to http://mymac.local/~me/index.html
~me/Sites/mysite/home.html which doesn't work
If I try http://mymac.loca...
I have a project to setup an anonymous feedback form to our website. I wanted to have a go at it with php
the general idea is that I would have a password field (give out to our employees) a field for the feed back and a button to
Ive seen this code snippet
<?php
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow ar...
Hiya,
I was wondering if anyone knows how to automatically convert PDF's to JPGs in Drupal when a user uploads, i'm able to create a script to do the actual conversion but my dilema is being able to catch the file on upload and the process it. (or if there is a script/module that already does it it would be even better!).
Thanks in adv...
I need split string by commas and spaces, but ignore the inside quotes, single quotes and parentheses
$str = "Questions, \"Quote\",'single quote','comma,inside' (inside parentheses) space #specialchar";
so that the resultant array will have
[0]Questions
[1]Quote
[2]single quote
[3]comma,inside
[4]inside parentheses
[5]space
[6]#spec...
I am trying to convert any occurrence of a word with 3 chars or less to the same word with the string VVV attached to it.
Example: for -> forVVV
I am using none Latin chars (UTF8), hence the MB.
What I have is:
$pattern='\b[.{1,6}]\b';
$text=mb_ereg_replace($pattern,'\0VVV',$text,'me');
What am I missing?
Here is a case study, see ...
Hi all.
I have a problem wich is a little strange. My page contains a html link which refreshes the page and calls a PHP variable. This variable appends a date string to the url string which is fed into a MySQL query, which grabs records matching this date. I think this is causing an injection as it sometimes deletes the user from the d...
I am new to php and MySQL. I have a site where a user can choose a state and display hospitals in that state. It works well in FireFox for all states, but in IE, when I have state with a couple hundred hospitals, the screen flashes and I eventually get a message that the page cannot be displayed. For smaller states with a few hospital...
I have a page that displays a user's current personal information and a handler that cycles through the form elements, filtering them through to the relevant mysql query. There are two tables, one that contains the master data, e.g. username, email, password hash, and one that has address data. However, the script doesn't work and I can...
Zend_Tool is nice, it generates a project with a given name & a given path.
But after a while, i started to develop my own tools, like helpers, plugins, validators, etc...
I put them all in library, which is ok (and recommanded).
But, i would have to start my project with the same bootstrap file, including initialization of my plugins...
I have a web-based system built with user login data based on session variables.
Sometimes when a user is logged in and tries to export tables to csv or xls the session data seems to wipe and the user is 'kicked out' of the system.
This is the header code I'm using to serve the file.
header("Pragma: public");
header("Expires: ...
Hi all,
If I'm getting my data from Mysql like so:
$result = $dbConnector->Query("SELECT * FROM branches, businesses WHERE branches.BusinessId = businesses.Id ORDER BY businesses.Name");
$resultNum = $dbConnector->GetNumRows($result);
if($resultNum > 0)
{
for($i=0; $i < $resultNum; $i++)
{
$r...
Hello,
I have a database abstraction layer that starts with a base class like so:
class DB {
function DB() {
$this->host = "xxx";
$this->db = "xxx";
$this->user = "xx";
$this->pass = "xx";
$this->dbh = mysql_connect($this->host, $this->user, $this->pass);
mysql_select_db($this->db);
// etc
}
}
class DB...
Hi all...
i'm trying to do the following hope there's a reg_ex expert around to shed some light.
I need to replace the character [ in my code and make it a {. But there is cases where the [ needs to remain a [ and not change. So the way i figured it is i need to use the
preg_replace("[", "{", $string);
function with a suitable regula...
With error reporting on, or even for best practice, when unsetting a variable in PHP, should you check to see if it exist first (in this case it does not always exist) and the unset it, or just unset it?
<?PHP
if (isset($_SESSION['signup_errors'])){
unset($_SESSION['signup_errors']);
}
// OR
unset($_SESSION['signup_errors']);
?>
...
Is it safe to pass raw base64 encoded strings via GET parameters?
...
all,
I wanted to create a multiline textbox but all the info i googled on it says that i can adjust the length but no the height
How would i create a text box field that i could have a user type comments into for a php script?
this is what I'm currently using
<INPUT TYPE = "TEXT" >
Bonus question:
how do i disable enter in the tex...
does following this work on linux server?
<? require 'foldername/header.php' ?>
the above code is present in home.php. home.php is in folder foldername.
...
I need help, below is a small VERY basic regex to somewhat validate an email, I do realize it does not work the greatest but for my needs it is ok for now.
It currently uses PHP's eregi function which php.net says is now a depreciated function and I should use preg_match instead, simply replacing erei with preg_match does not work, can...
I have PHP 5.1.6 running with a ton of mods and extensions enabled, is there a way to reconfigure the current settings as well as add SOAP to the mix?
...