Jump to content

Dale_G

Members
  • Posts

    74
  • Joined

  • Last visited

    Never

Everything posted by Dale_G

  1. Alright, thank all three of you for a job well done!
  2. Not having much luck with array_filter, and gevans after trying your code after a print_r I get Array ( [0] => A )
  3. Say I have this array $aych = array( 'B', 'B', 'A', 'A', 'B', 'A', 'A', 'B', 'B', 'A' ); and when i do a print_r right now i get... Array ( [0] => B [1] => B [2] => A [3] => A [4] => B [5] => A [6] => A [7] => B [8] => B [9] => A ) now what i need to happen is, loop through ALL keys in the array and check if there values are B, if they are, then remove it from the array and shift everything forward. foreach ( $aych as $key => $value ) { if ( preg_match( '{B}', $value ) ) { array_splice( $aych, $value, 0 ); } } i was able to loop through them all, and check if the value is B, as shown above. I know you use the array_splice function for this, but im not exactly sure how to properly utilize this in this environment. in the end, if i print_r it, i need to get Array ( [0] => A [1] => A [2] => A [3] => A [4] => A ) which is after all of the B's are removed and the array moved foward. does anyone know how to do this?
  4. Oops, I meant like where everything shifts over afterwards, so its as if it was never there and $maybe[3] could still be called, it would just be "xxxxxx" now. Basically, delete one item from an array, and shift everything over so all the keys are preserved. Sorry!
  5. hey, i was wondering if its possible to delete an item from an array? $maybe = array( 'xx', 'xxx', 'x', 'abc', 'xxxxxx' ); How could I remove "abc" ($maybe[3]) from the array entirely so that the array would now look something like this: $maybe = array( 'xx', 'xxx', 'x', 'xxxxxx' );
  6. String = 'hello!howare!yo!u?'; Look for the first occurrence of x, which in this case is '!', and then return the first section prior to x, which in this case would be 'hello'. How would that be done?
  7. You know that made ALOT of sense, thank you. Oh but, as far as that proxy method goes, still possible right? If so, how?
  8. Hey there. I'm using cURL to retrieve the contents of a page, this page, happens to echo out the IP Address, via echo '<b>IP:</b> '.$_SERVER['REMOTE_ADDR']; Now, I was able to successfully change, and set both the referer AND the user agent, to anything. Is this possible with the IP Address as well? Basically, how can I have it so when I try to request the page that echos out the IP address, it echos out something I, not the server, designates, such as '11.111.111.111' for example, if it's even possible. Thanks!
  9. Hello there, just a quick question, does anyone know exactly what curl_setopt( $ch, CURLOPT_VERBOSE, 1 ); does or means? What's the different between having it and not having it, please explain, not just "o it writes to the STDERRRERE", thanks!
  10. Right, that works! When I said without the use of keys I meant like, keys in the actual array ( 'apple' => 0 ), this is great, thank you thorpe!
  11. Without the use of keys if I may add, just a plain ol' array!
  12. Hello everyone, long time no post...but anyway, I have a little problem here, which probably has a very easy solution, see if you can help me out here... This is an array. $fruits = array( 'apples', 'oranges', 'bananas', 'pineapples' ); And, obviously I can access "apples" by $fruits[0]; And that's alright. But, how can I get it's numeric value just from the string? Ex. If I enter apples I want 0 returned, if I enter bananas I want 2 returned, etc. If that makes sense, getting the numeric position based on the array value.
  13. Hello everyone, right so I am including an external file as such... require( 'members.php' ); And I've confirmed it works, using this syntax everything is fine. echo $members->show('all'); It shows all of the members, it does what it is supposed to do. However, when I throw it into a function and attempt to call the function, as shown below... function show_members() { echo $members->show('all'); } show_members(); It does not work and throws a "Fatal error: Call to a member function on a non-object" error, and I know why. I can remedy this problem by adding "global $members;" to the function, like this. function show_members() { global $members; echo $members->show('all'); } So now, the completed working file is shown below. require( 'members.php' ); function show_members() { global $members; echo $members->show('all'); } show_members(); And that's fine. However as I develop this project there will be MANY choices that require different calls to different functions, so I will be making over 30 functions similar to show_members(), that call different functions under the $members class. Basically, what I'm wondering is if there is a way to "globally" declare the $members class. So I don't have to type "global $members;" in each function...as that can get rather bothersome the more functions I add. Also, I will probably throw this into a class later on, so if there is a way to globally declare it for the class, that would be awesome.
  14. Hey everyone, basically I have two includes named 'connect.php' and 'connect2.php', they consist of the following code... $username = ''; $database = ''; $password = ''; $host = ''; mysql_connect( $host, $username, $password ); @mysql_select_db( $database ); Of course, with the proper values filled in for the respective database. When I try to include them both in a file, one of them seems to get "ignored' and the SQL queries that need that file don't work, however one of them does. I know WHY this doesn't work, I just need to know a solution so that I can include a file and can run different queries on different databases.
  15. Hey again! Basically I was wondering about classes in PHP. I've heard about different types of functions, public private and protected and I've noticed in some classes people use '::' alot. So I was just wondering if someone could explain a little bit about classes and such, maybe write a really quick dummy class to help show what each type of function does maybe? But any help would be appreciated!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.