amedhussaini
Members-
Posts
29 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
amedhussaini's Achievements
Member (2/5)
0
Reputation
-
Creating 'feed' of activity--most efficient setup?
amedhussaini posted a topic in Application Design
Hi everyone, We have a social networking iPhone application that is constantly making API calls to our server in order to bring in information and write information to the database. Every time a friend is added, a comment is created, etc (basically in a bunch of different tables things are being created)--we want this stuff to show up on one screen, like a facebook 'feed'. I've thought about approaching this two ways, and I'd like some advice from the experts out there on the more efficient way to do it. 1. a lot of DB writes--in other words, everytime a user does something that does belong in the feed (like comment on something, or like something), at the same time the api can add a row to a new 'notifications' table. that way, when i need to pull a feed for someone later on, i can just pull from this one table 2. one big read--currently, i don't have it setup like the above--the plan was to just query all the tables when u want to refresh your feed.. my api will return a big xml doc to the iphone and then the iphone will rearrange the data as needed what do you think is the better approach? -
Find any questions in strip_tagged($Web_Page)?
amedhussaini replied to amedhussaini's topic in Regex Help
err, that was silly.. that was part of my print_r output that i mistook for something else. thx again fellas. -
Find any questions in strip_tagged($Web_Page)?
amedhussaini replied to amedhussaini's topic in Regex Help
Thanks! This works like a charm. Ran it on a few test cases... 99% were accurate, came up with a few of these: : What is RSS? ) What is the WTO? ) Any ideas on further refining it? For now, I will study your regex expression and decipher how you came up with it... this place really is a wealth of knowledge -
Trying to search a $string (just an HTML page grabbed with curl after stripping the tags) for questions. I thought to look to return content between "What" and "?" inclusive, etc... but no luck so far. Valid questions I'm looking for: "What is the point?" "what is the point?" I'd like the function to return all results into an array if possible Cheers, Amed
-
str_replace - how to skip certain search/replace rules?
amedhussaini replied to amedhussaini's topic in PHP Coding Help
hrm.. this still seems to change my replacement right back as it traverses the array. i must be missing something fundamental: $search = array('/one/', '/1/'); $replace = array('1', 'one'); $a = preg_replace($search, $replace, $a); Just to reiterate, i want it to search through the $string and replace the 'one' it finds with '1' or change any '1' it finds to 'one' the FIRST time it searches through the string. so i'd like the string to transform from: i like one 1 one ////after replacement//// i like 1 one 1 -
str_replace - how to skip certain search/replace rules?
amedhussaini replied to amedhussaini's topic in PHP Coding Help
Interesting. Could you perhaps go into a bit more detail (using the example I did)? -
I have a STRING full of text ($a) $search = array('one', 'two'); $replace = array('two', 'one'); $a = str_replace($search, $replace, $a); I want to replace 'one' with 'two' in a string if it exists, but i don't want it to revert back to 'two' as it traverses the next bit of the array. Does this make sense? cheers, Amed
-
Hello, Thanks for the suggestions. I just read up on array keys. I could use an associated array storing each key word and corresponding numbers--are there other ways? How would I assigned a key between two arrays to preserve order when sorting (a quick code snippet if possible).. I'm going to try to implement the associate array and do a simple sort on that but I'd love to see multiple ways of doing for the learning factor. Thanks!!
-
??? Ugh. I've been googling this and reading the php manual for hours now, but I can't quite figure out how to sort a 2d array. I always reserve this place as a last resort, I hate to fill up these boards with simpleton questions. Here goes: I have a 2 array called $final, some example output: $final[0][0] contains the string "pregnancy" $final[0][1] contains the integer "25" $final[1][0] contains the string "baby" $final[1][1] contains the integer "14" You might have guessed, I've written a scraper that ranks the amount of key words on a page. I have the $final 2d array with each keyword and the amount of times they appear, but they're out of order. How might I sort this array by the integer DESC? Thanks so much in advance.
-
is this a valid practice? i'm working on my first OOP class that deals with user registration.. can i have a, for example, $sqli = new mysqli(); within the method that will "register" and insert variables into my table? I've found a few tutorials on this.. the one i'm working out of deals with procedurally connecting to the database and inserting information, but can i do it object oriented style? amed
-
mysqli_connect abstracted into include file help
amedhussaini replied to amedhussaini's topic in PHP Coding Help
thanks.. yeah, i know, all i have to do is include it.. but i was *trying* to do a function based one and couldn't get it to work.. i'd like to see what one that works looks like hehe -
mysqli_connect abstracted into include file help
amedhussaini replied to amedhussaini's topic in PHP Coding Help
thanks man. anyone have a function that does similar? -
Can someone here past their include file they use to initialize their databases? I'm having trouble abstracting all my connect statements.. as it stands right now, i do the whole: $mysqli = mysqli_connect("...... etc everytime Cheers, amed
-
Hey all, Tried running a search, I couldn't find much information. Anyone have a code snippet to 'POST' a <FORM> with Ajax? I'm basically coding a shoutbox for my page. The code is all done.. it works, displays the shouts, etc.. but when I POST submit to my shoutbox_insert.php, it goes to the blank php file while it inserts and I have to hit back to see the update. Anyone got a snippet handy for this?
-
thank you so much everyone! cheers, amed