Hello, I seem to have a small problem, in the code below $a_trip is always true, even if $trip!= $admin_trip. Any idea why?
if($trip == $admin_trip)
$a_trip = true;
if($a_trip == true)
$trip = ("~::##Admin##::~");
I have an object, let's say it's like this:
class Foo {
var $b, $a, $r;
function __construct($B, $A, $R) {
$this->b = $B;
$this->a = $A;
$this->r = $R;
}
}
$f = new Foo(1, 2, 3);
I want to get an arbitrary slice of this object's properties as an array.
$desiredProperties = array('b', 'r');
$output = magicHere($foo, $desiredProperties);
print_r($output);
// array(
// "b" => 1,
// "r" => 3
// )
move_uploaded_file() won't work for me anymore, it was working fine and just stopped out of nowhere. Is there a way for me to check why it's not working anymore? Here's what I currently have, but it only returns TRUE or FALSE.
$status = move_uploaded_file($tempFile, $targetFile);
if($status) {
echo 'its good';
} else {
echo 'it failed';
}
I know the path is 100% correct and the directory is CHMOD 755. Is there anything I might be doing wrong?
I have a function that outputs items in a different order depending on a random number. for example 1/2 of the time Popeye's and its will be #1 on the list and Taco Bell and its logo will be #2 and half the time the it will be the other way around. The problem is that when a user reloads or comes back to the page, the order is re-randomized. $Range here is the number of items in the db, so it's using a random number between 1 and the $range.
$random = mt_rand(1,$range);
for ($i = 0 ; $i < count($variants); $i++) {
$random -= $variants[$i]['weight'];
if ($random <= 0) {
$chosenoffers[$tag] = $variants[$i];
break;
}
}
I went to the beginning of the session and set this:
if (!isset($_SESSION['rannum'])){
$_SESSION['rannum']=rand(1,100);
}
With the idea that I could replace the mt_rand in the function with some sort of pseudo random generator that used the same 1-100 random number as a seed throughout the session. That way i won't have to rewrite all the code that was already written. Am I barking up the wrong tree or is this a good idea?
Hi,
I use DOMDocument. My code here.
$dom = new DOMDocument('1.0', 'utf-8');
$textNode = $dom->createTextNode('<input type="text" name="lastName" />');
$dom->appendChild($textNode);
echo $dom->saveHTML();
Output:
<input type="text" name="lastName" >
But i want to disable htmlentities. How can i do?
I have an XML file like this:
<?xml version="1.0" encoding="UTF-8"?>
<gallery>
<album tnPath="tn/" lgPath="imm/" fsPath="iml/" >
<img src="001.jpg" />
<img src="002.jpg" />
</album>
</gallery>
I am reading the file with:
$xmlFile = "xml.xml";
$xmlStr = file_get_contents($xmlFile . "?" . time());
$xmlObj = simplexml_load_string($xmlStr);
Now I am rebuilding the XML file and would like to save the album node with it's attributes in a var
I was thinking with xpath:
// these all return arrays with the images...
// echo $xmlObj->xpath('/gallery/album@tnPath');
// echo $xmlObj->xpath('//album[@tnPath]');
// echo $xmlObj->xpath('//@tnPath');
But that doesn't seem to work? Any help?
I'm trying to strip content titles out of the middle of text strings. Could I use regex to strip everything out of this string except for the title (in italics) in these strings? Or is there a better way?
Joe User wrote a blog post called
The 10 Best Regex Expressions in the category Regex.
Jane User wrote a blog post called
Regex is Hard! in the category TechProblems.
I've tried to come up with a regex expression to cover this, but I think it might need two. The trick is that the text in bold is always the same, so you could search for that, like this:
regex: delete everything before and including wrote a blog post called
regex: delete in the category and everything after it.
I am trying to add the new Facebook log in button to my registration page on my Drupal site.
I know the following code is wrong, but I don't know the right syntax to implement it:
function facebook_user($op, &$edit, &$user, $category = NULL) {
switch($op) {
// User is registering.
case 'register':
// Add a Facebook login button.
echo '
';
}
}
What should I use instead of echo? Is there another way I should be going about this?
Thanks
take this string as an example: "will see you in London tomorrow and Kent the day after tomorrow".
How would I convert this to an associative array that contains the keywords as keys, whilst preferably missing out the common words, like this:
Array ( [tomorrow] = 2 [London] = 1 [Kent] = 1)
Any help greatly appreciated.
Say I have a hashmap,
$hash = array('fox' => 'some value',
'fort' => 'some value 2',
'fork' => 'some value again);
I am trying to accomplish an autocomplete feature. When the user types 'fo', I would like to retrieve, via ajax, the 3 keys from $hash. When the user types 'for', I would like to only retrieve the keys fort and fork. Is this possible?
What I was thinking was using binary search to isolate the keys with 'f', instead of brute-force searching. Then continue eliminating the indexes as the user types out their query. Is there a more efficient solution to this?
<tag>
????? ?
</tag>
When I try to get the content of the following code using DOMDocument functions, it returns something like:
ÐÐ»ÐµÐºÑ Ðœ
I've tried setting DOMDocument encoding to different values (UTF-8, ISO-8859-1), using mb_convert_encoding, iconv and utf8_encode but without success.
How can I get "????? ?" instead of "ÐÐ»ÐµÐºÑ Ðœ" ?
EDIT: The input is coming from a page loaded with curl. When I output the page content to my browser, the characters are displayed correctly (so I doubt the input is the problem).
convert this: $300
to this : 300
can't do it with intval() or (int)
typecasting
if the non-numerical character is
suffixed (300$), both works and
returns 300
if it is prefixed it returns 0
the non-numerical character can be anything other than the "$"(i.e. "askldjflksdjflsd")
Please help
Hi :)
I'm looking for a nice newsletter management solution.
I tried CCmail a good script but whaere I can't imort usernames !!!
I would like to find a system that is able to import Opt-in lists in the following format :
John Smith;[email protected];other paramaeters...;[like] ;Male;Age...
I will develop my own module if I could find another emailing manager
Are you already satisfied with a similar application with a trusted (spam-prevention) emailer ?
Thank you :)
hi every one
i am trying to echo session id i saw that each time refreshing the page it chang thats why i cant login .
please any one suggest wht prob should be there
I'm looking to create a multi page ordering form the first page would contain some dropdown and text fields, the second page would contain more text fields, the third page would be an order summery with paypal payment option.
I'm just wondering what the best way to create this order form is. I've used sessions in the past but never with users entering in text and picking items from drop downs, does anyone have any resources for doing this? Or does anyone know of a jquery or other ajax example or plugin I might be able to use and modify.
any insight would be a big help.
thanks
I'm trying to find a way to return the value of an array's parent key.
For example, from the array below I'd like to find out the parent's key where $array['id'] == "0002".
The parent key is obvious because it's defined here (it would be 'products'), but normally it'd be dynamic, hence the problem. The 'id' and value of 'id' is known though.
[0] => Array
(
[data] =>
[id] => 0000
[name] => Swirl
[categories] => Array
(
[0] => Array
(
[id] => 0001
[name] => Whirl
[products] => Array
(
[0] => Array
(
[id] => 0002
[filename] => 1.jpg
)
[1] => Array
(
[id] => 0003
[filename] => 2.jpg
)
)
)
)
)
Hi guys! how would you turn this array:
array(
0 => Title1,
1 => Title2,
3 => Address1,
4 => Address2,
)
to this array:
array (
0 => array(
'title' => 'Title1'
'address' =>'Address1'
),
1 => array(
'title' => 'Title2',
'address' => 'Address2'
)
);
when you were initially given
$_POST['title'] = array('Title1', 'Title2);
$_POST['address'] = array('Address1', 'Address2');
which when merged would give you the first array I have given
I was able to solve this via a high level Arr:Rotate function in Kohana framework, along with Arr::merge function but I can't quite understand the implementation. Please help
I'm playing about with a stop words within my code I have an array full of words that I'd like to check, and an array of words I want to check against.
At the moment I'm looping through the array one at at a time and removing the word if its in_array vs the stop word list but I wonder if there's a better way of doing it, I've looked at array_diff and such however if I have multiple stop words in the first array, array_diff only appears to remove the first occurrence.
The focus is on speed and memory usage but speed more so.
Thanks
I had a client who had MySQL Strict which brought up a few errors in my MySQL code... I didn't even know there was a MySQL Strict. I've fixed up a lot of the issues but I want to run some further tests on my local server.
How do I enable MySQL Strict for testing purposes and then disable it when I no longer want it?
i got a sales web site each time i press "sales" button it it will open a new frame.
there is a possibility for more then one frame at the same time.
my problem is i want to close the frame after i click enter and home page to be updated provided all the other pending sales frames are remain open....
i tried to do so with window concept also no use
so any body can geve a solution
regards