« first day (647 days earlier)      last day (4291 days later) » 

Word
 
I just found a big bunch of comments on my PHP 5.5 post here: habrahabr.ru/post/147674/#comment_4980242
I really need to improve my Russian reading ^^
 
aren't you Russian ^^
 
I am :D
but it takes me a lot of time to read russian text ^^
 
@NikiC Go go gadget Google translate
 
2:06 PM
@webarto pashol nahuy
(i run out of beer)
 
@tereško pashol na kuricu :D
 
that's not a saying (also .. how the hell is it related to chickens ? )
 
@NikiC Yeah, I saw that a few weeks ago
 
:D
 
@NikiC , i have the same problem
 
2:08 PM
I'm just not used to those cyrillic letters ^^
 
i read the word , and then have to guess how it should sound
 
You spend too much time on the internet :P
Reading english text
 
First line of every conversation with Russian person begins with something like this: вуощ оуышдш щемщкшщ флфгте
 
@NikiC: born in Russia? Or just russian decent?
 
also , watching LoL stream where french and swedes are talking un english is fun
 
2:10 PM
@ircmaxell born in russia ;)
 
Ah, interesting
 
btw , the size of this chat has gown to five lines
 
father of my brothers wife fled to Russia after WW2, and his father never talked to him after that, Ze German proud
 
@NikiC How come you're in my neighborhood now then? (Or was that the other way around?)
 
@deceze ur in my neighborhood!
 
2:13 PM
@deceze , there is noone near you : you live on a small island of ruby developers
 
@NikiC Ahh, after all... ;P
 
hahahahhahahahhahahahah
 
@tereško I only have my beach house there.
 
riiight
 
survived tsunami? probably on the other side of the island
 
2:17 PM
@webarto Tsunami wasn't a problem, the earthquake was pretty close though.
@NikiC Seriously though, you migrated with your parents? If I may ask, that is...
 
Woot, up to 940 followers
@NikiC: off hand, is the GC run while an execption is bubbling up the stack?
 
@ircmaxell sure
@deceze yeah, my father works here at the university ;)
 
so as it traverses up each stack entry, it runs the GC on that stack?
 
it goes up each stack frame and inserts a HANDLE_EXCEPTION opcode
in there it cleans up pushed stack args and loop variables (and maybe more)
and then passes control to the leave handler
which then also frees the compiled variables / symbol table
and this pointer and whatever else there is
 
Hey all.
anyone up for a mysql question?
 
2:24 PM
(And probably some stuff more, but that's basically what is going on. For everything else, see the source ^^)
 
Ah
 
We have an order field in the database that we want to maintain for each relationship type
Does it make more sense for me to select the max(order) and then insert into the db ? or do the select inside of the insert?
This is what I have now:
 
see ya later
 
            INSERT INTO %s (`taskId`, `relationshipId`, `relatedTaskId`, `taskOrder`)
            VALUES ( ?, 1, ?, IFNULL((  SELECT
                                            MAX(`taskOrder`)+1 as `maxOrder`
                                        FROM
                                            %s `tr`
                                        WHERE
                                            `relatedTaskId` = ?
                                        GROUP BY `relatedTaskId`), 1)   --  if the max is null, then the order is `1`
It is parameterized for mysqli
and it works fine.
but it seems hacky...
 
later
 
2:26 PM
@NikiC latr
Guess not... ?
 
I'll show you hacky, heh...
 
@webarto o will you now?
 
the colours.. my eyes!
 
@webarto How much time, if any, did you spend trying to make that query work in Doctrine (DQL)? :p
 
2:36 PM
@webarto lol. Side Q: What is "CAST"? aka what does it do?
 
@MikeB I found it impossibru with the table scheme I was given :)
 
@MikeB lol thats a useless explanation
 
Take this data and make it of X type. i.e. if you had a varchar field with integers you could cast it to an int
 
But doesnt mysql already know how to do those comparisons?
It always has for me
 
2:39 PM
it is probably not needed in my example because I already "formatted" it...
 
@webarto yaa
 
That's one thing that worries me about MySQL... some of the magic it does and how that relates to portability.. even with OTHER mysql instances
 
SELECT CAST('9:44' AS TIME);
09:44:00
 
2:56 PM
@MikeB
> The most important sql_mode values are probably these:
If they don't know who does?
 
it depends on what you're doing
 
dear god i hate sharepoint
 
seems like a strange statement
 
I don't know a lot about MySQL but the settings on that page remind me of PHP's safe-mode, magic-quotes, etc
I'm sure they have their uses but they make portability difficult
dev.mysql.com/doc/refman/5.0/en/… Why would you want to change that behavior?
 
@MikeB You can set the modes at run-time
 
2:59 PM
@gorelative We have to use a huge asset management system based on sharepoint and it sucks.....hard!
 
im responsible for my departments sharepoint site, adding content editing widgets.. it blows.
 
no, it sucks. :)
 
dude nice flex
that tire is STUFFED
 
@rlemon That's the beauty of infinity. Everything is collectively possible at infinity
 
Im trying to sort an array of images by last modified date, but many of the dates are exactly the same and using usort drops those images with the same date. This is the function im trying to use to get around that, but it isnt working, any ideas?
function cmp_by_filemtime_and_basename($a, $b) {
$cmp = filemtime($a) - filemtime($b);
if ($cmp == 0) {
$cmp = strcmp(basename($a), basename($b));
}
return $cmp;
}
usort($temp_files, 'cmp_by_filemtime_and_basename');
 
3:02 PM
http://stackoverflow.com/questions/11633668/convert-date-into-timestamp-for-compare-2-dates
 
@Leigh Just beat me to it :)
 
@vascowhite Yea I saw your commenting, top related question answers his question
 
@ircmaxell yup :) it's hard to wrap your head around it. I try not too...
 
Thanks Leigh i will take a look
 
assuming we believe in the multi-verse and within it contains an infinite number of universes, and each universe is governed by a finite set of rules, there will be every possible outcome for all possible choices (observable or not) produced. Also this would mean because there is no end to the number of universes but there is an end to the permutation each universe can see; there is also an infinite number of exact copies of all universes in the multi-verse.
So in some other universe you are also reading this sentence.
and in another you are a hot dog.
 
3:10 PM
in another universe i could kill you via chatting
 
0
Q: recursive descend parser - avoiding left recursion

Jinu J DI have the following productions A -> Aa A -> b so it is clear that there is left recursion like parseA() { parseA();//recursion parsea(); } It is said that the left recursion can be avoided using the following rule A -> bA' A' -> aA'|null How is left recursion avoided ...

 
I love the concept of "Almost Surely"
 
probably maybe?
 
Is there a possibility that an arbitrary, x+1th MySQL user is prohibited from accessing the INFORMATION_SCHEMA database? I want to make sure that the code I am working on is deployable with the less compromises and I am at the step of desinging a check whether the set database exists or not.
 
x+1th?
Information_Schema is always available. It's not a real database, but a virutal one. If you have select access to anything on the server, you'll have access to information_schema data about that table/schema...
 
3:19 PM
Like: a proper noone. From the developer's point of view, you can't be sure what sort of rights will the (database) user have. That's why I should make it sure to use the MySQL calls only with the basic and needed tools which is (generally) available to everyone.
@ircmaxell Thank you. So I can make use of this: stackoverflow.com/a/838993/1428773
 
is there any PHP cache that work's great on shared hosting
 
@Whisperity if you can connect to the server, yes.
HOWEVER, it won't do what you think it will
It will only tell you if the db exists and you have select permission on it or one of its tables
So if it doesn't return from that query, you have no idea if it's because it doesn't exist, or you don't have permissions for it
But there's no other way to do that, short of checking on the filesystem (which requires even more access)
 
@ircmaxell Well, the connection is checked against in a previous step. What I need in this step is that if ( $database_exists ) { forward(); } else { create_db(); }
 
if you have permissions to create a database
 
If the database requested exists but we don't have permission from the application, the database is just as good as not being existant at all. I will make sure that I check against every possible solution with an account which is revoked from such privileges.
And after a whole year, my IP address has changed.
 
3:32 PM
Hi all ^^
 
Do someone know how to do a mkdir() to create a dir on another hdd?
@PeeHaa How are you?
 
pretty good
 
Flag and Edit queues are way down today.. something happen?
 
3:34 PM
@MikeBoutin mkdir("D:\foobar"); or mkdir("/path/to/mount/point/foobar");
 
@Whisperity on localhost it doesnt work :/
Warning: mkdir() [function.mkdir]: No such file or directory
 
@MikeBoutin permissions issue?
 
@MikeBoutin Does the webserver user (usually www-data under Linux) has write rights to the parent directory where you want to make the folder?
 
i'm with wamp and i want to create a folder on my R: from my C:
ok... i guess it's a permission issue
it work on my D:
ty guys
 
I need to develop a Wordpress plugin, is there a plugin for that?
7
 
3:40 PM
Do you know if it's possible to do it on a internal Network?
 
@webarto Please elaborate and clarify.
 
@MikeB haha you can't escape the pings!
 
@Leigh :D
 
@MikeBoutin You mean, to call mkdir() over LAN on another computer? I don't think so. Apart from running a PHP script on the target computer (with a webserver) and passing the folder variable over a HTTP call or something like that.
 
The other Mike went and changed his name, and then Mike #3 turns up to add insult to injury
 
3:43 PM
42
 
@Whisperity I have the right to create files and folders on the shared network. Can i mkdir from my computer ?
 
@Neal is that the answer to my question?
 
@webarto sometimes.
 
@MikeBoutin Do you have a networkshare mounted as a drive?
 
@Neal Sometimes? Always!
 
3:44 PM
@MikeBoutin If the remote computer is mounted on your computer too. Take a mounted smbfs "partition" in /mount/foobar, you can go mkdir("/mount/foobar/bazqux"); to create a folder if you have the write access.
 
@PeeHaa yes i think... the "drive" name is R:
 
@deceze :-P
 
@MikeBoutin In that case I think you should be able to create stuff on the mounted drive
 
:$
can anyone help with a quick array question? i have this json decoded. How can i get the first(only)title out of it?
 
@Leigh Im not sure what the answer in the link provides. If filemtime for two files is the same how can i then just compare names? $cmp = strcmp(basename($a), basename($b)); seems like it would work.
 
3:53 PM
@Glen020 Do var_dump on the json_decoded data
 
@Glen020 $response->data->children[0]->data->title
var_dump(json_decode($json_string)); is your friend
 
@Glen020 $foo = json_decode( file_get_contents("http://reddit.com/.json?limit=1") ); $title = $foo->data->children[0]->data->title;
 
Hrm, need to think of a topic for Friday's blog post...
 
@ircmaxell Common misconceptions in (the head of) PHP (developers)?
 
3:56 PM
^ lol how much time do you have?
 
@Whisperity in what sense?
 
@Whisperity and @MikeB Thank you soo much. i've been looking at the dumps and print_r's. recursive loops and me don't get along
 
@Src1988 wat?
 
@Glen020 When you read a var_dump() it's important to note the data-type of each node in the tree. In your case there were objects mixed in with arrays so it can get a little confusing.
Try stepping through each node one at a time instead of writing the whole thing
It can be cumbersome but you'll have more hair left in the end :)
 
my problem is i don't have it formatted neatly,
i tried to run parser's on it to no avail
 
4:03 PM
For my question above, you sent a link regarding changing a date to a timestamp, but im not sure how that helps. In the function i have
$cmp = filemtime($a) - filemtime($b);
but if $cmp = 0 then i compare basenames with strcmp, but when i run the sort it only sorts by name and not filemtime.
 
@Glen020 For formatting var_dumps I'd highly recommend installing xdebug (xdebug.org), alternatively you can print a <pre> before the var_dump to make it easier
 
@ircmaxell legacy code!
 
yeah, that's a possibility...
 
I don't remember you ever blogging about it
 
@Glen020 Your var_dumps should look something like this pastebin.com/wptK9Suf
 
4:06 PM
 
or just use <pre>...
 
@ircmaxell How much do you know about PHP's memory management? You could talk about the '1 second lifetime' PHP scripts are supposed to shoot for
 
1 second lifetime? Since when is that a goal? I have PHP applications that have been running for literally months...
 
back
 
Aye, same here.. but I heard Johannes Schlüter mention 1 second as the ceiling to shoot for when operating under normal conditions in this video youtube.com/watch?v=bxxIXPc9IR8
He didn't expand past that.. I'll see if I can track down the time in the video
 
4:10 PM
@NikiC wb
 
I think for web requests 1 second is WAY too long...
 
oh, hi @PeeHaa
 
@MikeB ( The first letters of the slide headers are missing.)
 
@MikeB @Whisperity when used on my site, my vardumps look like this :( pastebin.com/gsrsQPwd
 
@ircmaxell what about the fact that there are still a lot of websites out there with very basic security flaws in it and the fact that they shouldn't be allowed to programming anything
 
4:12 PM
hey, guys, i have another problem :(
 
@Glen020 Install xdebug or prefix your dumps with <pre>
 
@ircmaxell Why did you start writing that much?
 
i dont knw how to read mail using php (imap)
 
@ircmaxell About the fact that you find easily find targets using google and download entire databases and stuff like that and the fact that it is very easy to build decent protection
 
i've found a code somehwere, i tried it on my server but its not working :(
can i paste the code here? any help?
 
4:13 PM
@PeeHaa Oh good god, forget that...
 
@ircmaxell ?
 
@NikiC Why not... I don't know, it feels good to gain traction...
 
@PeeHaa :P if thats the case then i wont be allowed t do programming as an hobby :(
 
@PeeHaa our apache logs are littered every day with people fishing for a phpmyadmin directory :P
 
@NokImchen Create a Gist or a Pastebin entry, don't post loads of code into the shat.
 
4:14 PM
@PeeHaa if I said what I really feel about that...
 
@ircmaxell Just wondered whether there is any specific reason ;)
 
@NokImchen That's my point. Well you are allowed to build stuff as long as you don't store personal information about people
 
@Whisperity oh, nice idea :) Thanks :)
 
@ircmaxell :-)
 
4:15 PM
@MikeB Sorry for sounding like a tool, but how do you prefix a dump?
 
@Glen020 echo '<pre>'; var_dump($foo);
 
@PeeHaa ya! ur right :) cos really, storing others personal info with no security is really bad :(
 
@NokImchen You can also (if the question is having a longer lifetime) post a question on the main site. Just format it properly.
 
hey, here is the link pastebin.com/KsV3jYzA
 
@MikeB Oh, wow. i tried like 6 parser functions that all sucked badly! soo much prettier. THanks!
 
4:16 PM
@Leigh
 
@NokImchen Check for permissions first. IMAP server is avialable (valid)? Connectable from your webserver?
 
@Whisperity actually, posting questions is more complicated cos i cant ask questions to their answers. Commenting on the comments sometimes take days to get the reply :(
 
@Leigh Well I have to admin I have dropped every sort of cryptographical stuff while my project is under refactoring.
 
ya, i think so!Mail Server Username: anok+werewfrdsfdsfd.tk
Incoming Mail Server: mail.werewfrdsfdsfd.tk
Incoming Mail Server: (SSL) in6.hostgator.in
Outgoing Mail Server: mail.werewfrdsfdsfd.tk (server requires authentication) port 25
Outgoing Mail Server: (SSL) in6.hostgator.in (server requires authentication) port 465
Supported Incoming Mail Protocols: POP3, POP3S (SSL/TLS), IMAP, IMAPS (SSL/TLS)
Supported Outgoing Mail Protocols: SMTP, SMTPS (SSL/TLS)
 
Take The Pledge and promise to never try to invent your own algorithms again. Just use bcrypt, there's no reason to do what you're trying to do (and it's not secure in the least, not even close to it)... — ircmaxell 5 secs ago
 
4:18 PM
@Whisperity thats what my server gave me :)
 
Hi! I have always managed to evade the use of regex, but now i cannot. How should i build a regex that matches "#word#" when "word" doesn't have a length-limit (as in, it can be "#total#" or "#mynameisjohn#") ?
 
@ircmaxell I think he was trying to say "I can do 10k hashes a second, whats the point in bcrypt"
 
@ircmaxell From Johannes Schlüter: "Most of the PHP memory management is focused on the case that we are in the webspace and a typical php script is running way less than a second. If a php script is running longer than a second in MOST cases there's something wrong." (youtube.com/… Start 23 minutes in).
 
@MikeB if a web request is running longer than a second, I agree
but not in general
 
@MikeB I have a daemon written in PHP :x
 
4:19 PM
Hey guys!
 
@MikeB omg! sometimes my scripts run for more than 10 seconds!
 
To refine my suggesting: What goes into designing a memory manager that makes it operate optimally in <1sec operation
Holy crap people I'm not saying PHP can't run >1 second
2
 
@ircmaxell he's not even talking about the full request, just the script, for which 1 sec seems waaaaaay too long
 
@MikeB :P
 
@orourkek My point is that if you're talking about using PHP for a web request, then yes, 1 second is the longest... but that's not the only use of PHP...
 
4:20 PM
hey quick question, where is the optimal spot to close a mysql connection? Should I do it right after I've stored the results of the query in a var, or should I leave it open until the end of the function?
 
@MikeB Hm, I guess incremental garbage collection isn't required for things that have a short runtime
 
@TomC Why do you need to close the connection?
 
@PeeHaa I wasn't sure if I needed to or not, I know it'll close on its own but isn't it a best practice to explicitly close it?
 
@TomC Neh just let it die unless you have a really good reason to close it
 
@PeeHaa oh okay, thank you! :D
 
4:23 PM
np
 
@Leigh I guess what I was leading to is Are there any time-sensitive operations that goes on internally to PHP? Something like if (run_time > 1sec) garbage_collect_less_often();
(horrible example).. but something where time is measured and behavior changes
 
I don't think so, I think it's more to do with it doesn't care about keeping memory tidy over long periods
 
is it normal that Regex makes no sense to me?
i cannot, for the love of me, gather its content.
 
hey guys I have a programming etiquette question. When reading another person's code, do you prefer to have the opening curly bracket be on the same line as the function name, or the next line?
 
4:27 PM
> Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
 
my passwords are regex patterns
 
@MoshMage /#\w+#/
 
2
Q: MySQL GROUP_CONCAT as multiple fields and custom order

hookmanHere is a structure of my tables: Here is what I want as a result of a query (considering that user provides me with 2|4|1 pattern): Here is what I tried: SELECT parcel.TrackCode, parcelType.Name, GROUP_CONCAT(track.DateTime SEPARATOR '|') AS dt FROM track JOIN parcel ON track.ParcelID = par...

 
@TomC Consistency is more important than the details.. whichever you choose make it consistent. Personally, I prefer the new line
 
@TomC Y U IGNITE FLAMEWAR
 
4:28 PM
@TomC if () { // same line
 
@deceze hahaha! >:D
 
@deceze thank you so much. but what Mike said might be true. As soon as he said it i thought "how will i distinguish the matched result after?" xD
 
@TomC function something() // next line
And my CS is law ;-)
 
next line for the love of god
 
same line FTW
 
4:29 PM
ruby rocks
php sucks
 
There are only 2 semantically valid brace positions:
 
lol
 
I'm a one-liner too
 
hahaha you guys make me happy that you do it on the next line too... all my professors do it on the same line and it drives me crazy for no real reason :P
 
if ($foo) {
    bar();
}

and

if ($foo)
    {
    bar();
    }
 
4:30 PM
wtf? @ircmaxell
 
i have this "rulle" that if i can spare lines, i will.
 
anything else gives false semantic information
 
I do it on the same line
 
@ircmaxell my hero
 
It marks the start of the block, makes sense it would be on the same line :|
 
4:30 PM
@MikeB WTF, that's even worse
 
Don't thank me, thank Steve McConnell...
 
@TomC If it's properly seperated and the code is readable (like: usage of whitespace characters to indicate sub-blocks), it's en.wikipedia.org/wiki/Toilet_paper_orientation.
 
@ircmaxell I always respected you until now ;)
 
In computer programming, an indent style is a convention governing the indentation of blocks of code to convey the program's structure. This article largely addresses the C programming language and its descendants, but can be (and frequently is) applied to most other programming languages (especially those in the curly bracket family). Indent style is just one aspect of programming style. Indentation is not a requirement of most programming languages, where it is used as secondary notation. Rather, programmers indent to better convey the structure of their programs to human readers. In pa...
 
4:31 PM
Ok. Since i have never used preg_match before.. this is going to be a bumpy ride. x)
 
@MoshMage rubular.com
 
@MikeB Yeah, but... Ahh, FI, @TomC Y U IGNITE FLAMEWAR
 
hahaha what have I done! :)
 
Sorry.. I told myself I wasn't going to get into this
 
Ok, lunch
 
4:32 PM
I only need to replace (for now) 3 words, and i am using a str_replace that's not replacing crap; deceze was kind enouhg to make a regex for what i want *but*

does it justify to use regex for 3 (possibly 5) matches?
 
@ircmaxell enjoy
 
there is no lunch in war
 
@MikeB Lets be friends \(^∀^)メ(^∀^)ノ
Food~
 
consistency > any petty squabble over newlines :)
 
4:34 PM
154
A: The Many Memes of Meta

TheTXIMeme: jQuery Originator: Unknown (possibly Ólafur Waage) Cultural Height: TBD Background: A Stack Overflow-centric meme, jQuery begin its career early on as the answer to beat for any question that even remotely referenced JavaScript. Its popularity became so great that eventually jQuery becam...

 
Personally, I prefer to nuke all my newlines.. that way I get 100% code-coverage with a single require :D
 
/me is getting frustrated
maybe i'm not aproaching this right.
 
how do i go about changing #name# to $_POST["name"] ?
 
@MoshMage If you can post a short example of the text you want to search and replacement-rules you'll probably get a better answer
 
4:38 PM
text is: "hello #name#! mighty fine of lalala #link#."
 
@PeeHaa How you going to answer a question you voted to close
 
ahcrap. I'm even having trouble expressing myself.
 
@MikeB I answered it and after that I thought it should be a dupe. hence
 
let me get a hold of myself.. --'
 
Can i do multiple command shell actions in a row ? Like in the real command shell? shell_exec("r:");
shell_exec("mkdir aaa");
 
4:41 PM
@MikeBoutin You know PHP also has mkdir() builtin right?
 
i know
but i can't do my mkdir in the network
 
@MikeBoutin I don't think this is an approach on Windows as the next shell_exec won't be ran on R:. If you were using Bourne shell, you could go shell_exec("something && foo && bar && whatever");, however.
 
u remember my question?
 
@MikeBoutin yup
 
@Whisperity i can't change my shell_exec path?
 
4:42 PM
system
 
@MikeBoutin Set the webserver user to a user who can mkdir. Or create a Batch file with PHP (fopen, fwrite, fclose) and then use only one shell_exec, starting that Batch file.
 
I am making this "answer back" where you can set a default message and when the user registers it sends a mail to that person with the answer you saved.

Then i thought about "why don't i make it so the user (admin) can choose where the link and username go?"
So, #name# and #link# are said variables;
I tried with something simple "Hello #name#! here is your #link#"

somehow, str_replace() does not replace things for what i want; #name#! fails to match the replace and #link# just disapears.

How do i go about doing this?
 
Hey guys
 
(cablam!)
 
@MoshMage Use another kind of prefix and postfix for variables like ?? I use $this->_buffer = str_replace( "{[" .$k ."]}", $v, $this->_buffer);.
 
4:44 PM
@MoshMage 7
 
@Whisperity that can be great! ^^
 
hey Truth
 
@Truth hey
 
@MoshMage Use something non conventional like $$name$$.
@Neal 42
 
@Whisperity Do you know where i can find some infos about developing that way?
 
4:44 PM
seriously?! that's what might be wrong with it? lol.
here i was thinking all hell broke lose.
I'm going to try that :)
 
@MoshMage It shouldn't be the problem though
 
@Truth HIKE!
 
yeah, my hopes aren't that high either ^^'
but wait!
if #name#! doesn't match and #link# matches but it's not replaced
something else is at fault.
 
@MikeBoutin Batch is the way of scripting the Windows Command Prompt. Just $foo = fopen("bar.bat", 'w'); fwrite($foo, "R:\r\n"); fwrite($foo, "mkdir somefolder\r\n"); ... fclose($foo); and then shell_exec("bar.bat");.
 
@MoshMage Using this code:
<?php

$str = "This is my #name#, and here's my #link#.";
$str = str_replace("#name#", "Truth", $str);
$str = str_replace("#link#", "http://stackoverflow.com", $str);

echo $str;
produces: This is my Truth, and here's my http://stackoverflow.com.
So that's not the problem
Can you make a testcase which reproduces the problem?
 
4:48 PM
This is what i have

$phrase = "Hello #name#! goto #link#";
$catch = array('#name#','#link#','#total#');
$link1 = getCfg("shopurl").'/index.php?order='.$orderId.'&email='.$_POST['email'];
$replc = array($_POST['nome'],$link1,$grandtotal);
$message = str_replace($catch, $rplc, $phrase);
 
$str = str_replace(array("#name#", '#link#'), array("Truth", "http://stackoverflow.com"), $str);
 
You can go $dblayer = "db_" . $cfg['dbtype']; $db = new $dblayer(param); but can't $db = new "db_".$cfg['dbtype'](param);?
 
@MoshMage better iterate, you'll just confuse yourself...
 
@webarto that's what i'm doing. ...i think.
 
@webarto $replace = array('name' => "Truth", 'link' => "foo://bar"); foreach ($replace as $k => $v ) { $str = str_replace("#".$k."#", $v, $str); } would be more suitable if $replace is a very long array.
 
4:51 PM
yes, I told him to iterate...
 
i just learnt a new word. Iterate. Still, am i not doing the same thing?
 
he can do array_combine if he has two arrays to start with...
@MoshMage that is what the i stands for in loops...
 
oy? then i totally not learnt a word. still. I do not have any for loop?!
 
@MoshMage The way you do it (with the two arrays) can turn out to be confusing. If I were able to post newlines in my code, you would see that it is a lot less confusing that way. And you are, in the end, doing almost the same, except that in this case, each replace has its own str_replace call.
 
@Whisperity thanks for sorting that out :)
i need to get out of the house. Still; I thought that str_replace didn't need a loop - it would replace everything by itself
 
4:57 PM
function _i($str, array $values = array())
{
    if ( ! empty($values))
        foreach($values as $key => $value)
            $str = str_replace(':' . $key, $value, $str);

    return $str;
}
@MoshMage
 
@webarto How did you do multiline code format?
 
CTRL + A, CTRL + K, or click fixed width button on the right
 
eitherway, thanks for the help; i need to go out. can't think.
 

« first day (647 days earlier)      last day (4291 days later) »