Jump to content

[SOLVED] Where there's a will there a way?


elmas156

Recommended Posts

Hey guys, I'm trying to make some things work on my site and I'm having to try some different things.  What I'm trying to do is to take a string of text that has been set to a variable and extract certain parts of that string of text to make another variable.  For example:

 

<?php

$text = "dog/chicken/fish";

//then change this to:

$4legs = "dog";
$2legs = "chicken";
$nolegs = "fish";

?>

 

**Note: This is just an example... I do not really need to make variables to show how many legs a dog, chicken and fish have... only an example to simplify what I'm trying to do ;-)

Link to comment
https://forums.phpfreaks.com/topic/123264-solved-where-theres-a-will-there-a-way/
Share on other sites

Great, it works.  What I'm actually trying to do is work with dates and compare them to the current date while sticking with a specific format.  Trying to work with date() functions wasn't getting me anywhere so I needed to revert to trying to break down a text string date (09/15/2008) and pull out just the year in order to compare it to current the current date obtained through php ($cyear=date("Y");).  What you suggested works great.  Thanks discomatt!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.