My form works in firefox but not ie. I've tried using a hidden text field (fail)... I tried using an image instead of a submit button (fail)... are there any other solutions?
Is it more efficient to use the key intersect or the value intersect if both key and value have the same contents for example:
Array
(
[743] => 743
[744] => 744
[745] => 745
[746] => 746
[747] => 747
[748] => 748
)
Is there any difference in performance in using one or the other with the same values. Similar to the difference of using double or single quotes?
Been battling with this one for what seems, like forever.
I have an array:
$url_array
It contains this info:
Array (
[ppp] => Array (
[0] => stdClass Object (
[id] => 46660
[entity_id] => 0
[redirect_url] => http://www.google.com
[type] => Image
)
[1] => stdClass Object (
[id] => 52662
[entity_id] => 0
[pixel_redirect_url] => http://www.yahoo.com
[type] => Image
)
[2] => stdClass Object (
[id] => 53877
[entity_id] => 0
[redirect_url] => http://www.msn.com
[pixel_type] => Image
)
)
[total_count] => 3
)
I need to loop through it, and do things to each variable. I can get this to work:
foreach ($piggies_array as $key => $value) {
$id = $value[0]->id;
$redirect_url = $value[0]->redirect_url; }
Not unsurprisingly, it's only echoing the first value of those variables, but no matter what I try I cannot get it to loop through:
$value->redirect_url;
$value=>redirect_url;
I would appreciate any help.
I am setting up dynamic forum signature images for my users and I want to be able to put their username on the image. I am able to do this just fine, but since usernames are different lengths and I want to right align the username, how can I go about doing this when I have to set x & y coordinates.
$im = imagecreatefromjpeg("/path/to/base/image.jpg");
$text = "Username";
$font = "Font.ttf";
$black = imagecolorallocate($im, 0, 0, 0);
imagettftext($im, 10, 0, 217, 15, $black, $font, $text);
imagejpeg($im, null, 90);
I have 3 featured product panels on the homepage, and I'm writing a CMS page for it. I'm trying to validate the items.
They are selected via three <select> elements, featured1, featured2 and featured3. The default is <option value="0" selected>Select an element</option>
I need to validate the $_POST to ensure that the user hasn't selected the same product for more than one of the panels.
I have worked out that each $_POST needs to be $_POST['featuredN'] > 0 but I can't seem to find a logical way of processing the 7 potential outcomes. Using a logic table, where 1 is a set value.
1 2 3
-------
0 0 0
1 1 1
1 0 0
0 1 0
0 0 1
1 1 0
0 1 1
If an item is 0, then I will not update it, but I want the user to be able to update a single item if needs be.
I cannot find a logical way to see if the item is not 0, and then compare it to another item if that also is not 0.
So far my colleague suggested, adding up the values. Which works to see if condition 1 0 0 0 is not met.
I have a vague feeling that some form of recursive function might be in order, but I can't quite get my brain to help me on this one! So to the collective brain! :)
Hi, I'm trying to output lists of objects as json and would like to know if there's a way to make objects usable to json_encode? The code I've got looks something like
$related = $user->getRelatedUsers();
echo json_encode($related);
Right now, I'm just iterating through the array of users and individually exporting them into arrays for json_encode to turn into usable json for me. I've already tried making the objects iterable, but json_encode just seems to skip them anyway.
In a function like this
function download($file_source, $file_target) {
$rh = fopen($file_source, 'rb');
$wh = fopen($file_target, 'wb');
if (!$rh || !$wh) {
return false;
}
while (!feof($rh)) {
if (fwrite($wh, fread($rh, 1024)) === FALSE) {
return false;
}
}
fclose($rh);
fclose($wh);
return true;
}
what is the best way to rewrite last few bytes of a file with my custom string?
Thanks!
Hi my question
Need to get the 10 word before and 10 words after for the given text . i mean need to start the 10 words before the keyword and end with 10 word after the key word.
Given text : "Twenty-three"
The main trick : content having some html tags etc .. tags need to keep that tag with this content only . need to display the words from 10before - 10after
content is bellow :
<div id="hpFeatureBoxInt"><h3><a href="/go/homepage/i/int/news/world/1/-/news/1/hi/world/europe/8592190.stm">Suicide bombings hit Moscow Metro</a></h3><p>Past suicide bombings in Moscow have been blamed on Islamist rebels At least 35 people have been killed after two female suicide bombers blew themselves up on Moscow Metro trains in the morning rush hour,<h2><span class="dy">Top News Story</span></h2> officials say.<img height="150" width="201" alt="Emergency services carry a body from a Metro station in Moscow (29 March 2010)" src="http://wwwimg.bbc.co.uk/feedengine/homepage/images/_47550689_moscowap203_201x150.jpg">Twenty-three died in the first blast at 0756 (0356 GMT) as a<a href="#"> train stood </a>at the central Lubyanka station, beneath the offices of the FSB intelligence agency.About 40 minutes later, a second explosion ripped through a train at Park Kultury, leaving another 12 dead.No-one has said they carried out the worst attack in the capital since 2004. </p><p id="fbilisten"><a href="/go/homepage/i/int/news/heading/-/news/">More from BBC News</a></p></div>
Thank you
I've run into a typical problem here. Till now i was doing
strstr($filename,".");
$filename is the file i got from $_FILE i.e uploaded file.It was running fine until i hit a filename of the type i mentioned.
Even doing
pathinfo($filename);
gives me
.gz
I need to see whether it is EXACTLY
.tar.gz
Hi, for a certain project, I need some way to parse XML and get data from it. So I wonder, which one of built-in parsers is the fastest?
Also, it would be nice of the parser could accept a XML string as input - I have my own implementation of thread-safe working with files and I don't want some nasty non-thread-safe libraries to make my efforts useless.
I'm writing a little homebrew ORM (academic interest). I'm trying to adhere to the TDD concept as a training exercise, and as part of that exercise I'm writing documentation for the API as I develop the class.
Case in point - I'm working on a classic "getCollection" type mapper class. I want it to be able to retrieve collections of asset X (let's say blog posts) for a specific user, and also collections based on an arbitrary array of numeric values. So - you might have a method like any one of these
$User = $UserMapper->load(1);
$ArticleCollection = $ArticleMapper->getCollection(range(10,20));
$ArticleCollection = $ArticleMapper->getCollection($User);
$ArticleCollection = $ArticleMapper->getCollection($User->getId());
So, in writing the documentation for the getCollection method - I want to declare the @param variable in the Docblock. Is it better to have a unique method for each argument type, or is it acceptable to have a method that delegates to the correct internal method/class based on argument type?
This is my code.
if(in_array("1", $mod)){
$res=array('First Name','Insertion','Last Name','Lead Country');}
if(in_array("2", $mod)){
$res=array('Landline No:','Mobile No:','Lead Country');}
if(in_array("3", $mod)){
$res=array('City','State','Country','Lead Country');}
if(in_array("4", $mod)){
$res=array('Email','Lead Country');}
return $res;
Upto this it works fine. But if the array contains more than one value say (1,3)
I need to return both results of 1 and 3.
eg: if the array is like this
array([0]=>1 [1]=>3)
then
$res=array('First Name','Insertion','Last Name','City','State','Country','Lead Country')
But if there are 2 lead country only one should be displayed how to do this?
Pls help me.
My English is poor so I will make it short.
Right now, I have imzip.zip which has three txt files:
a.txt
b.txt
c.txt
When I try to load imzip.zip using:
http://pastebin.com/m1d974990
It loads the files alphabetically. In this case:
a.txt
b.txt
c.txt
However, I would like to be able to have the class load on different variables such as by size, date or simply random.
The problem is I have no idea how I would go about modifying the class to fit my needs.
I would really appreciate your help! :D
Hello,
I'm hoping somebody knows the answer :).
Within wordpress in the users section I would like to add a new row which will data pulled in from the Register Plus plugin.
Where would I need to create a new row?
My Example:
Username Name E-mail Role **Website** Posts
Admin Admin [email protected] Administrator google.com 2
Thanks.
I've got a script that reads in from a CSV file and sometimes the CSV files it receives contains an uneven amount of delimiters/columns so the first row could have 30 columns, the 2nd could have 20, etc. I can think of a few solutions myself ie:
Count the delimiters in the widest row, then append the proper amount to each row that is short to make them even.
But I was wondering if anyone had a more elegant method of doing this.
Every time I start apache , it always fails.
The problem is in loadmodulephp5...
The error log:[warn] pid file C:/windows/Apache2/logs/httpd.pid overwritten — Unclean shutdown of previous Apache run?
I tried to delete this file and then start apache.But this file had been created again.
Any solution?
Hello
i need to refresh combo box (sub category ) related to what i choose in main category combo box , for example if i choose "chicken" in main category , the value of sub category will be "grilled chicken" , " fried chicken " ? how should i do this ?
<select name="categorylist" id="categorylist">
<?
$sql_query= mysql_query("select category_id,category_name, from categories");
while($fetch= mysql_fetch_array($sql_query))
{ ?>
<option value= " <? echo "$fetch[category_id];" ?> " selected="selected"><? echo "$fetch[category_name]"; ?> </option>
<?
}
?>
what should i put in subcategory ?
I decided to make a recent view box that allows users to see what links they clicked on before. Whenever they click on a posting, the posting's id gets stored in a cookie and displays it in the recent view box.
In my ad.php, I have a definerecentview function that stores the posting's id (so I can call it later when trying to get the posting's information such as title, price from the database) in a cookie. How do I create a cookie array for this?
**EXAMPLE:** user clicks on ad.php?posting_id='200'
//this is in the ad.php
function definerecentview()
{
$posting_id=$_GET['posting_id'];
//this adds 30 days to the current time
$Month = 2592000 + time();
$i=1;
if (isset($posting_id)){
//lost here
for($i=1,$i< ???,$i++){
setcookie("recentviewitem[$i]", $posting_id, $Month);
}
}
}
function displayrecentviews()
{
echo "<div class='recentviews'>";
echo "Recent Views";
if (isset($_COOKIE['recentviewitem']))
{
foreach ($_COOKIE['recentviewitem'] as $name => $value)
{
echo "$name : $value <br />\n"; //right now just shows the posting_id
}
}
echo "</div>";
}
How do I use a for loop or foreach loop to make it that whenever a user clicks on an ad, it makes an array in the cookie? So it would be like..
1. clicks on ad.php?posting_id=200 --- setcookie("recentviewitem[1]",200,$month);
2. clicks on ad.php?posting_id=201 --- setcookie("recentviewitem[2]",201,$month);
3. clicks on ad.php?posting_id=202 --- setcookie("recentviewitem[3]",202,$month);
Then in the displayrecentitem function, I just echo however many cookies were set?
I'm just totally lost in creating a for loop that sets the cookies. any help would be appreciated
I am using this to get real IP but i take empty from $_SERVER['HTTP_CLIENT_IP'],i take not empty only from $_SERVER['REMOTE_ADDR'].But i dont need the IP of proxy,i need the real ip of computers using some intranet.Can i get it?when $_SERVER['HTTP_CLIENT_IP'] does not return empty?
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
Hello in my database date / time are stored in this format
2010-06-01T18:20:25+0000
I'd like to echo that out to time passed since that date / time
e.g.
2 minutes ago or 2 days ago
is this possible?
I am trying to create a simple inventory request system. A user can enter multiple SKU's that will query the inventory database.
My problem is I am trying to do is associate these multiple queries into a type of list. This list can later be retrieved and contains all queries that were submitted simultaneously. When the list is filled it can then be deleted.
Is this possible? I am just looking to be pointed in the right direction.
Thanks