Search found 17 matches

by us2rn4m2
Thu Aug 07, 2014 7:46 am
Forum: PHP coding => General
Topic: How to append php string values into another string
Replies: 1
Views: 359

Re: How to append php string values into another string

Code: Select all

echo str_replace(array('A0', 'AB0'), array('A4', 'AB8'), "A0B0C0D0E0F0AB0AC0"); 
// A4B0C0D0E0F0AB8AC0
by us2rn4m2
Fri May 23, 2014 1:37 pm
Forum: PHP coding => General
Topic: Retrieving text
Replies: 3
Views: 856

Re: Retrieving text

Code: Select all

echo strstr('username my_username', ' '); // my_username
by us2rn4m2
Fri May 23, 2014 1:26 pm
Forum: PHP coding => General
Topic: How to remove beginning up to end of searched 2 characters?
Replies: 0
Views: 466

Re: How to remove beginning up to end of searched 2 characte

Code: Select all

$url = 'https://www.fb.com/SmilePg/posts/320187951230342';
echo substr(strrchr($url, '/'), 1);  // 320187951230342
http://www.php.net/manual/en/function.parse-url.php
http://www.php.net/manual/en/book.strings.php
by us2rn4m2
Fri May 23, 2014 12:45 pm
Forum: PHP coding => General
Topic: string manupulation
Replies: 0
Views: 411

Re: string manupulation

Code: Select all

$string = 'bik_bij_12_something.jpg';
echo substr($string, 0, strrpos($string, '_', 3)); // bik_bij_12
http://www.php.net/manual/en/book.strings.php
by us2rn4m2
Sun Feb 03, 2013 4:25 am
Forum: PHP coding => General
Topic: Replacing a Value within a Multi-Dimensional Array
Replies: 2
Views: 1543

Re: Replacing a Value within a Multi-Dimensional Array

// Option 1 $a['a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5'] = null; $a['a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5'] = 'ABC'; print_r($a['a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5']); // Result: ABC // Option 2 $a['a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5'][0]['value'] = null; $a['a3f9a1ba-85a2-4142-b0d6-6a85bef30cb5'...
by us2rn4m2
Mon Jan 28, 2013 6:21 am
Forum: PHP coding => General
Topic: having issue on curl_init
Replies: 2
Views: 1204

Re: having issue on curl_init

Ok, I am sending you an example that I wrote when I started to learn PHP: $url = 'http://www.webservicex.net/length.asmx/ChangeLengthUnit?'; $params = array( 'LengthValue' => '100', 'fromLengthUnit' => 'Kilometers', 'toLengthUnit' => 'Miles'); $request = $url . http_build_query($params); function cu...
by us2rn4m2
Wed Nov 21, 2012 9:16 am
Forum: PHP coding => General
Topic: Checking page name to change links class
Replies: 4
Views: 1119

Re: Checking page name to change links class

Yeah but your code works for me, so ? $_SERVER['PHP_SELF'] value must be exactly the same as "/path/" . $menuItems[$i] . ".php" This is my $_SERVER['PHP_SELF'] value: "/projects/php/index.php" and yours ? PHP manual say: "PHP_SELF The filename of the currently executing script, relative to the docum...
by us2rn4m2
Wed Nov 21, 2012 8:26 am
Forum: PHP coding => General
Topic: Checking page name to change links class
Replies: 4
Views: 1119

Re: Checking page name to change links class

Hi,
(Sorry for my English)

Path is missing in this line:

Code: Select all

if($_SERVER['PHP_SELF'] == $menuItems[$i].".php") 
echo ($_SERVER['PHP_SELF']) == "/path/" . $menuItems[$i] . ".php"
by us2rn4m2
Tue Nov 06, 2012 1:49 pm
Forum: PHP coding => General
Topic: Simple PHP question - merging two codes
Replies: 2
Views: 775

Re: Simple PHP question - merging two codes

<?php if ($format == 'gallery') : ?> <div id="spotlightg"> Contributer Spotlight </div> <div id="gcontent"> <header class="entry-header"> <?php do_action( 'gpp_before_title' ); ?> <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'gpp' )...
by us2rn4m2
Mon Oct 08, 2012 9:02 am
Forum: PHP coding => General
Topic: read file & show a part of it
Replies: 0
Views: 478

Re: read file & show a part of it

Hi, /** * fileName : page * Description : description of file * Version : 1.0 */ class Example {} $rc = new ReflectionClass('Example'); var_dump($rc->getDocComment()); Result: /** * fileName : page * Description : description of file * Version : 1.0 */ http://www.php.net/manual/en/book.reflection.php
by us2rn4m2
Mon Oct 08, 2012 8:44 am
Forum: PHP coding => General
Topic: Does str_replace have limits
Replies: 0
Views: 449

Re: Does str_replace have limits

No parse error in the first line.

Correction:

Code: Select all

$find  ='><a href="http://my.url.com/fancy-dress';
$_menu = str_replace($find, ' id="fancy-dress-tab"', $find);
echo $_menu;
http://php.net/manual/en/function.str-replace.php
by us2rn4m2
Mon Oct 08, 2012 8:14 am
Forum: PHP coding => General
Topic: Really need help with Strict Standards
Replies: 0
Views: 473

Re: Really need help with Strict Standards

Hi,

Your actual error reporting level is E_STRICT .
Change your error reporting level.

http://php.net/manual/en/function.error-reporting.php
http://www.php.net/manual/en/errorfunc.constants.php

or declare your method 'static'
by us2rn4m2
Mon Sep 24, 2012 12:05 pm
Forum: PHP coding => General
Topic: How to make str_replace to find multiple values
Replies: 0
Views: 210

Re: How to make str_replace to find multiple values

Hello,

Code: Select all

$search  = array('/', ' ');
$replace = array('_', '_');

$subject = 'Las Vegas';
echo str_replace($search, $replace, $subject); // output Las_Vegas

$subject = 'Las/Vegas';
echo str_replace($search, $replace, $subject); // output Las_Vegas
by us2rn4m2
Fri Sep 14, 2012 1:52 pm
Forum: PHP coding => General
Topic: split string on multiple char like '+' '-' '*' '/'
Replies: 0
Views: 408

Re: split string on multiple char like '+' '-' '*' '/'

Hi, Something like this ? <?php $a = "67* 90+ 86 -23"; $b = str_split($a, 2); echo '<pre>'; print_r($a); echo '</pre>'; /* Result: Array ( [0] => 67 [1] => * [2] => 90 [3] => + [4] => 86 [5] => - [6] => 23 ) */ $c = ''; foreach($b as $key => $value) { $v = trim($value); $c .= " '$v' "; } echo $c; //...
by us2rn4m2
Fri Sep 14, 2012 12:59 pm
Forum: PHP coding => General
Topic: Insert variable content into list()
Replies: 0
Views: 420

Re: Insert variable content into list()

Hi,

Code: Select all

$info  = array('brown', 'caffeine', 'hockey', 'football');
$sport = array();
                     //hokey   // football  
list($color, $power, $sport[0], $sport[1]) = $info;

echo $color . ' ' . $power . ' ' . $sport[0] . ' ' . $sport[1];

// Result: brown caffeine hockey football
by us2rn4m2
Thu Aug 09, 2012 2:47 pm
Forum: PHP coding => General
Topic: Getting the 5 most common values from a array
Replies: 5
Views: 606

Re: Getting the 5 most common values from a array

Hi, Yes it's possible! $array = array("a", "c", "b", "a", "b", "c", "d", "c", "b", "d", "d", "c", "d", "d"); $array = array_unique($array); // now count($array) = 4 rsort($array); for($i = 0; $i < 4; $i++) { if($i < count($array)) { // prevent an inexisting key echo $array[$i] . '<br >'; } } Result:...