Jump to content

oni-kun

Members
  • Posts

    1,984
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by oni-kun

  1. Imagine I use get_file_contents to place this plaintext into a variable.. Random: Test data: Hello Website: www.example.com ------ Time: 3:23PM Sky: Blue ------ Area: Space ------ END How could I extract..say.. the 'website' line, and what it says after ":" ? I'd prefer if there were a non-regex way if possible with subchar etc but it doesn't matter for it's a simple use, just text getting the 'something:key' to place into a variable.. Pseudocode: $stuff = get_file_contents('./file.txt'); $result = split($stuff, "website"); echo "Contact: <a href="$result">$result</a>";
  2. Essentially the standard characters which need to be escaped in " " are automatically escaped in ' ' .. Like the example above: $html = "<div ID=\"red\">Price: \$$price</div>"; $html = '<div ID="red">Price: $'.$price.'</div>'; '{code}' escapes automatically things such as.. ",$,\.. so notice you can only create a newline like "\n" not '\n' .. since it'll parse as literal... in '{code}' you ONLY need to escape (') and nothing else. It seems that you have a quote.. ", in the wrong place, you should post that line to show us which character is wrong..
  3. Works perfect! Thanks. I can now put a [whois] autogenerated link beside the host, it's useful for my project.
  4. Hello. I have a script which currently uses.. $fullhost = gethostbyaddr($ip); To get the host and it returns usually something long like.. d11.22.33.44.bschi.host.com .. I use $host = preg_replace("/^[^.]+./", "*.", $fullhost); and it seems make it.. "*.bschi.host.com" but I just want.. "host.com" How do I do this? I tried for hours last night to use strchr and strrpos etc but it always game out wrong.. how to I ignore everything before host.tld? Thank you! This is not an important application, so it can be basic..
  5. Thanks a million , As i'm a newbie to programming, I get how to do them, but I don't know the greater uses, in higher applications.. After this point my text RPG game looks fairly easy to accomplish, thanks again.
  6. That works on something like.. $rat = new Monster $rat->name = ... foreach ($rat as $val) { echo $val . "\n"; } But how do you list everything using the class Monster? class Monster -> $rat class Monster -> $skeleton How do you list all 'monsters' ( e.g. their names ) that are using the Monster class?
  7. For my first php project that I wanted to make, it is a simple game that includes a monster class. class Monster { (public variables, e.g. name) (functions...) } So I can call.. $rat = new Monster() $rat->name = "Rat" $rat->health = 20 How do I use foreach to list all created monsters? foreach ($monster as $key => $name) { echo "Monster: $key; Name: $name<br />\n"; } Or similar, but none have worked since it's a class and not an array.. I wish just to list all of the Monsters using that class, and with that their names/attributes..
×
×
  • 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.